Often see%~dp0 in batches, it seems difficult to understand.
In fact, it is%0, then use ~ to place between% and 0, add some definition fields to expand.
Echo%0
Echo%~0
This is made into a bat file that executes
E:\temp>echo "E:\temp\shenxu.bat"
"E:\temp\shenxu.bat"
E:\temp>echo E:\temp\shenxu.bat
E:\temp\shenxu.bat
%~0 is to remove the double quote "
%~F0 displaying the full catalog file
E:\temp\shenxu.bat
%~D0 Display Drive number
E:
%~P0 Display Path
\temp\
%~n0 display file name, not including extension
Shenxu
%~x0 Display Extension
Bat
%~S0 display shortened name, when the file name 8 bit, no change, more than 8 digits will display the top 6, and then add ~ and 1 and extension, and finally all of you into uppercase.
Shen12~1.bat
%~A0 Display properties, which are generally--a----
%~T0 Displays the time and date of the file
Echo 2015/08/11 15:49
%~z0 Display the file size
Then, they can be used in combination.
%~dp0 Show driver number good path
%~nx0 display file name and extension, in fact, full name
Sometimes see the%~DP1, actually is the expansion of%1, and so on the line.
This article from "Genius without that 1% is absolutely impossible" blog, please be sure to keep this source http://xushen.blog.51cto.com/1673219/1683641
Extensions to%0 in Windows cmd