Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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)

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

here is a list of common shortcuts:

%~f1 - expands %1 to a Fully qualified path name - C:\utils\MyFile.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

share|improve this answer
    
See also if /?, for /?, set /? –  grawity Dec 21 '10 at 13:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.