Batch file: how to get all remaining parameters after a SHIFT

  • Thread starter Thread starter Ronald Fischer
  • Start date Start date
R

Ronald Fischer

My Batch-File is supposed to work like this:

Invocation (variable parameter list):

MYBATCH.CMD FOO BAR P1 P2 P3....

Execution

(1) Execute MYBATCH_HELPER.CMD FOO
(2) Execute BAR P1 P2 P3 ....

How do I write this batch program? My first attempt went like this:

REM This MYBATCH.CMD does not work
MYBATCH_HELPER.CMD %1
SHIFT /1
%*

But this does not work, because %* always gets substituted by all
original parameters, ignoring the effect of any previous SHIFT.
Of course I could write it like this:

REM This MYBATCH.CMD works halfways
MYBATCH_HELPER.CMD %1
SHIFT /1
%1 %2 %3 %4 %5 %6 %7 %8 %9

But this is not really a variable parameter list, because there
can only be actual parameters P1 ... P8.

Any better solution to this?

Ronald
 
Ronald said:
My Batch-File is supposed to work like this:

Invocation (variable parameter list):

MYBATCH.CMD FOO BAR P1 P2 P3....

Execution

(1) Execute MYBATCH_HELPER.CMD FOO
(2) Execute BAR P1 P2 P3 ....

How do I write this batch program? My first attempt went like this:

REM This MYBATCH.CMD does not work
MYBATCH_HELPER.CMD %1
SHIFT /1
%*

But this does not work, because %* always gets substituted by all
original parameters, ignoring the effect of any previous SHIFT.
Of course I could write it like this:

REM This MYBATCH.CMD works halfways
MYBATCH_HELPER.CMD %1
SHIFT /1
%1 %2 %3 %4 %5 %6 %7 %8 %9

But this is not really a variable parameter list, because there
can only be actual parameters P1 ... P8.

Any better solution to this?

Ronald

I actually do not know the answer, but there is a really
great batch newsgroup that you can ask this question of.
I have great success with them:

alt.msdos.batch

HTH,
-T
 
I can't help you with batch files.
Have you used WXP's built-in command line reference a-z? There is an entry
for batch files which explains all the batch file commands with some
examples, including one for the use of the shift parameter.

-Paul Randall
 
I can't help you with batch files.
Have you used WXP's built-in command line reference a-z? There is an entry
for batch files which explains all the batch file commands with some
examples, including one for the use of the shift parameter.

I guess you mean

HELP SHIFT

??? But this does not say anything which would solve my problem.... As
you can
see from the code I have posted, I *do* use shift after all...

Ronald
 
Ronny said:
I guess you mean

HELP SHIFT

??? But this does not say anything which would solve my problem.... As
you can
see from the code I have posted, I *do* use shift after all...

Ronald

I've been following this thread with a degree of curiosity. I thought
that Todd's reply was spot on but so far I haven't noticed your
repost in the newsgroup he suggested. Paul's reply was, of course,
mildly amusing. Be it as it is, I confess that I do not fully understand
what you're trying to achieve. I agree that the shift command won't
have any effect on %* but I don't know what the purpose of the
whole exercise is. Perhaps a rephrase with an actual example might
lift the fog off my brain.
 
Back
Top