Saturday, December 15, 2007

DOS prompt file information

Ever need to get the size of a file or get the short DOS 8.3 name from the command line or from a BAT script. Simply type in "HELP FOR" in the DOS prompt to get help on the FOR command. In here you'll also find the nifty tags to get that special information about files passed as arguments. For example, %~s1 will get the short DOS 8.3 name of the first argument, %~z1 will get the file size, %~p1 will get the path, etc.

You may for example create a small BAT file (e.g. named dos83.bat) that contains the following line. When called it will show the short DOS8.3 name of the argument passed in.
@echo %~s1

Output Example:
U:\My Documents\My Templates>dos83 .
U:\MYDOCU~1\MYTEMP~1

Nifty

No comments: