What does %~dp0 mean, and how does it work?

后端 未结 7 2094

I find %~dp0 very useful, and I use it a lot to make my batch files more portable.

But the label itself seems very cryptic to me... What is the ~<

7条回答
  •  一整个雨季
    2020-11-22 02:53

    %~dp0 expands to current directory path of the running batch file.

    To get clear understanding, let's create a batch file in a directory.

    C:\script\test.bat

    with contents:

    @echo off
    echo %~dp0
    

    When you run it from command prompt, you will see this result:

    C:\script\

提交回复
热议问题