I'm looking at a batch file which defines the following variables:
set _SCRIPT_DRIVE=%~d0
set _SCRIPT_PATH=%~p0
- What do
%~d0
or%~p0
actually mean? - Is there a set of well-known values for things like current directory, drive, parameters to a script?
- Are there any other similar shortcuts I could use?
Yes, There are other shortcuts that you can use which are given below. In your command, ~d0 would mean the drive letter of the 0th argument.
As the 0th argument is the script path, it gets the drive letter of the path for you. You can use the following shortcuts too.
This can be also found directly in command prompt when you run CALL /? or FOR /?
From Filename parsing in batch file and more idioms - Real's How-to:
The path (without drive) where the script is : ~p0
The drive where the script is : ~d0
They are enhanced variable substitutions. They modify the %N variables used in batch files. Quite useful if you're into batch programming in Windows.
You can find the above by running
FOR /?
.