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.
Syntax | Origin | Description | Result |
---|---|---|---|
%~f1 | Full path | Full path | C:\data\ABC.csv |
%~d1 | Drive | Drive | C: |
%~p1 | Path | Path | \data\ |
%~n1 | Name | Name | ABC |
%~x1 | eXtension | Extension | .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.
Combination | Result |
---|---|
%~dp1 | C:\data\ |
%~nx1 | ABC.csv |
%~dn1 | C:ABC |
%~nd1 | C:ABC |
As can be seen in the examples of %~dn1
and %~nd1
, the order does not matter.
Environment
- OS: Windows11