What is %~dp0 in Windows batch file?

The path without drive letter where the batch file resides is given by: ~p0
The drive in which the batch file resides is given by: ~d0
In your command, ~d0 would mean the drive letter of the 0th argument.

~ expands the given variable
d gets the drive letter only
0 is the argument you are referencing

%~dp0 is the location in which the executing bat file resides.

When you see a statement as follows:

set CURRENTDIR=%~dp0

then you should know that ‘CURRENTDIR’ holds the path of the batch file location.

References: stackoverflow.com

Leave a Reply

Your email address will not be published. Required fields are marked *