%~ (percent tilde)

suggest change

When a command-line argument contains a file name, special syntax can be used to get various information about the file.

The following expand to various information about the file passed as %1:

Syntax Expansion Result Example
%~1 %1 with no enclosing quotation marks Not provided
%~f1 Full path with a drive letter C:\Windows\System32\notepad.exe
%~d1 Drive letter C:
%~p1 Drive-less path with the trailing backslash \Windows\System32\
%~n1 For a file, the file name without path and extension; for a folder, the folder name notepad
%~x1 File name extension including the period .exe
%~s1 Short 8.3 names only Not provided
%~a1 File attributes --a------
%~t1 Date and time of last modification of the file 02.11.2006 11:45
%~z1 File size 151040
%~pn1 A combination of p and n \Windows\System32\notepad
%~dpnx1 A combination of several letters C:\Windows\System32\notepad.exe
%~$PATH:1 The full path of the first match found in the folders present in the PATH variable, or an empty string if nothing matches.
%~n0 %~n applied to %0: the extensionless name of the batch tildetest
%~nx0 %~nx applied to %0: the name of the batch tildetest.bat
%~d0 %~d applied to %0: the drive letter of the batch C:
%~dp0 %~dp applied to %0: the folder of the batch with a trailing backslash C:\Users\Joe Hoe\

The same syntax applies to single-letter variables created by FOR command, such as %%i.

Links:

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents