What do %~df0 and %~df1 mean in a batch file?

Posted on


I have seen usages of %~df1 in a batch file but I don’t know what they mean. I have also seen %~df0 and I think that means the current directory of the batch file but I can’t find any documentation on this (bit hard to search for)


here is a list of common shortcuts:

%~f1 – expands %1 to a Fully qualified path name – C:utilsMyFile.txt

%~d1 – expands %1 to a Drive letter only – C:

%~p1 – expands %1 to a Path only – utils

%~n1 – expands %1 to a file Name, or if only a path is present (with no trailing backslash) – the last folder in that path

%~x1 – expands %1 to a file eXtension only – .txt

%~s1 – changes the meaning of f, n and x to reference the Short name (see note below)

%~1 – expand %1 removing any surrounding quotes (“)

%~a1 – display the file attributes of %1

%~t1 – display the date/time of %1

%~z1 – display the file size of %1

%~$PATH:1 – search the PATH environment variable and expand %1 to the fully qualified name of the first match found.

The modifiers above can be combined:

%~dp1 – expands %1 to a drive letter and path only

%~nx2 – expands %2 to a file name and extension only

courtesy of this website

Leave a Reply

Your email address will not be published.