I use this script to find out the current folder with its .bat file:
for /f %%i in (\"%0\") do set curpath=%%~dpi echo %curpath%
it does
for /f "delims=" %%i in ("%0") do set "curpath=%%~dpi" echo "%curpath%"
or
echo "%cd%"
The double quotes are needed if the path contains any & characters.
&