Suppose I wish to get the absolute path of a batch script from within the batch script itself, but without a trailing backslash. Normally, I do it this way:
SET
Example script "c:\Temp\test.cmd":
@set BuildDir=%~dp0. @echo Build directory: "%BuildDir%"
Run in console:
d:\> cmd /C c:\Temp\test.cmd Build directory: "c:\Temp\."