views:

67

answers:

2

What does the following %1 means (in a .bat file)?

jsmin <%1 >%2
+5  A: 

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.

Mehrdad Afshari
correct. more info is available via "call /?"
Andrey
+3  A: 

%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.

Tatu Ulmanen