logo

Expansion of Input Parameters for Batch Command 📂Programing

Expansion of Input Parameters for Batch Command

Code

Consider that one of several input parameters, the first argument C:\data\ABC.csv, is passed as %1 with a tilde included. Various functionalities of this input argument are introduced1.

SyntaxOriginDescriptionResult
%~f1Full pathFull pathC:\data\ABC.csv
%~d1DriveDriveC:
%~p1PathPath\data\
%~n1NameNameABC
%~x1eXtensionExtension.csv

Combination

The input argument can also be used in combination. Although combinations like %~dn1 may not have proper meaning as a file’s location, they can be cleverly used depending on the situation.

CombinationResult
%~dp1C:\data\
%~nx1ABC.csv
%~dn1C:ABC
%~nd1C:ABC

As can be seen in the examples of %~dn1 and %~nd1, the order does not matter.

Environment

  • OS: Windows11