Batch files - number of command line arguments
- by pyko
Just converting some shell scripts into batch files and there is one thing I can't seem to find...and that is a simple count of the number of command line arguments.
eg. if you have:
myapp foo bar
In Shell:
$# - 2
$* - foo bar
$0 - myapp
$1 - foo
$2 - bar
In batch
?? - 2 <---- what command?!
%* - foo bar
%0 - myapp
%1 - foo
%2 - bar
So I've looked around, and either I'm looking in the wrong spot or I'm blind, but I can't seem to find a way to get a count of number of command line arguments passed in.
Is there a command similar to shell's "$#" for batch files?
ps. the closest i've found is to iterate through the %1s and use 'shift', but I need to refernece %1,%2 etc later in the script so that's no good.