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
Instead of removing the trailing backslash, adding a trailing dot is semantically equivalent for many software.
C:\Windows is equivalent to C:\Windows\.
echo %dp0
>C:\Windows\
echo %dp0.
>C:\Windows\.
This errors out:
robocopy "C:\myDir" %~dp0
This is successful:
robocopy "C:\myDir" %~dp0.