find path of current folder - cmd

后端 未结 3 1770
既然无缘
既然无缘 2020-11-27 05:36

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

3条回答
  •  [愿得一人]
    2020-11-27 05:43

    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.

提交回复
热议问题