tags:

views:

3884

answers:

3

I'd like to find Windows batch counterpart to Bash's "$@" that holds a list of all arguments passed into script.

Or I have to bother with "shift"?

A: 

You can use %1, %2 etc to access the command line arguments. I don't think there's a variable that holds the entire list. You might be able to write a simple loop that determines how many arguments were passed.

EDIT: Apparently there is :)

codelogic
+8  A: 

%* seems to hold all of the arguments passed to the script.

dancavallaro
Missed it by 4 seconds. :)
EBGreen
Thanks. That's what I've been looking for.
wheleph
+6  A: 

dancavallaro has it right, %* for everything. You might also find these useful:

%0 - the name of the batch file itself
%1 is the first command line parameter,
%2 is the second command line parameter,
and so on till %9 (and SHIFT can be used for those after the 9th).

%~dpnx0 - is the fully qualified path name of the script (d:\scripts\some-batch.bat)
%~dp0 - drive and path to the script (d:\scripts)

More info examples at http://www.ss64.com/nt/syntax-args.html and http://www.robvanderwoude.com/parameters.html

matt wilkie