I know that %0 contains the full path of the batch script, e.g. c:\path\to\my\file\abc.txt
I would path to be equal to c:\path\to\my\file
How could I achieve that ?
I know that %0 contains the full path of the batch script, e.g. c:\path\to\my\file\abc.txt
I would path to be equal to c:\path\to\my\file
How could I achieve that ?
%~dp0 will be the directory. Here's some documentation on all of the path modifiers. Fun stuff :-)
To remove the final slash, you can use the :n,m substring syntax, like so:
SET mypath=%~dp0
echo %mypath:~0,-1%
I don't believe there's a way to combine the %0 syntax with the :~n,m syntax, unfortunately.
That would be the %CD% variable.
@echo off
echo %CD%
%CD% returns the current directory the batch script is in.