简体   繁体   中英

Batch file: for parameters

I am having trouble understanding what does following windows batch file do, can somebody explain:

for /f %%i in ("%0") do set curpath=%%~dpi
cd /d %curpath% 
/*Some other code...*/
cd /d %curpath%

%0 is the full path to the .bat file itself (if run from another directory) and ~dpi is a modifier to extract the drive and directory from a path omitting the file name, so this snippet sets the current drive & directory to the one in which the batch file lives.

I can't see the reason for using a FOR , %~dp0 does the same thing in one go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM