开发者

What are "%1" and "%2" in batch files?

开发者 https://www.devze.com 2022-12-21 01:14 出处:网络
What does the foll开发者_JAVA技巧owing %1 means (in a .bat file)? jsmin <%1 >%2 It represents the first command line argument passed to the batch file.

What does the foll开发者_JAVA技巧owing %1 means (in a .bat file)?

jsmin <%1 >%2


It represents the first command line argument passed to the batch file.

If you run your batch file with:

myfile.bat firstArg secondArg

%1 becomes "firstArg" and %2 becomes "secondArg"

The related shift command shifts the position of arguments one to the left. Running shift once in a batch file will make "%1" value to be the second argument, "%2" becomes the third, and so on. It's useful for processing command line arguments in a loop in the batch file.


%1 is the first argument given, %2 the second.

If you run the file with foo.bat source.js destination.js, the command run is jsmin <source.js >destination.js.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号