Manipulating arguments to a batch file

December 10th, 2008 | Categories: Windows | Tags: ,

I am creating a batch file for the command line, and I needed to parse out the arguments (e.g., get the filename, change the extension, remove the quotes, etc.).  I always forget these (and where to find them), so I’m copying them here.

%~1 - expands %1 removing any surrounding quotes (")
%~f1 - expands %1 to a fully qualified path name
%~d1 - expands %1 to a drive letter only
%~p1 - expands %1 to a path only
%~n1 - expands %1 to a file name only
%~x1 - expands %1 to a file extension only
%~s1 - expanded path contains short names only
%~a1 - expands %1 to file attributes
%~t1 - expands %1 to date/time of file
%~z1 - expands %1 to size of file
Comments are closed.