%~ (percent tilde)
suggest changeWhen 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 extensionFor a folder, the folder name | notepad |
%~x1 | File name extension including the period | .exe |
%~s1 | Modify of f, n and x to use short name | 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 in no match. | |
%~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 | %~f applied to %0:The drive letter of the batch | C: |
%~dp0 | %~dp applied to %0:The folder of the batch with trailing backslash | C:\Users\Joe Hoe\ |
The same syntax applies to single-letter variables created by FOR command, such as %%i
.
Links:
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents