I have a batch file (lets call it doit.bat) which calls doit.exe. doit.bat wants to sonsume the first 3 arguments, and pass any remaining ones to doit.exe. On unix I am used to shifting away the used arguments and hten passing on $*. However in dos %* seems unaffected by shift? is this really the case or am I missing somehting
doit.bat
set arg1=%1
shift
set arg2=%2
shift
.. do some stuff
doit.exe %3 %4 %5 ( there may be none or 20)
seems a bit silly to just specify %3 %4 %4 ... %20 .. %999
passing on unused parameters
Moderator: DosItHelp
Hi alasdair,
you are right, %* is unaffected by shift
But it exist another possible way.
Not perfect, but better than %4 %5 %6 ... %9
%999 does not work, because only %1 .. %9 are defined
%10 expands to "%1" and "0"
The other way
for /f "tokens=3*" %%a in ("%*") do doIt.exe %%b
Problems exists if one of the parameters %1 .. %n are of the form "a b" or
a;b, but if you only use "normal" paramters all works fine.
hope it helps
jeb
you are right, %* is unaffected by shift
But it exist another possible way.
Not perfect, but better than %4 %5 %6 ... %9
%999 does not work, because only %1 .. %9 are defined
%10 expands to "%1" and "0"
The other way
for /f "tokens=3*" %%a in ("%*") do doIt.exe %%b
Problems exists if one of the parameters %1 .. %n are of the form "a b" or
a;b, but if you only use "normal" paramters all works fine.
hope it helps
jeb