Jump to content

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


Recommended Posts

Guest Ronald Fischer
Posted

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 Fischer <ronaldf@eml.cc>

Posted via http://www.newsoffice.de/

  • Replies 4
  • Created
  • Last Reply
Guest ToddAndMargo
Posted

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

 

Ronald Fischer wrote:

> 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

Guest Paul Randall
Posted

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

 

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

 

"Ronald Fischer" <ronaldf@eml.cc> wrote in message

news:1186662348.14@user.newsoffice.de...

> 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 Fischer <ronaldf@eml.cc>

> Posted via http://www.newsoffice.de/

>

Posted

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

 

On 9 Aug., 23:15, "Paul Randall" <paulr...@cableone.net> wrote:

> 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

Guest Pegasus \(MVP\)
Posted

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

 

 

"Ronny" <ro.naldfi.scher@gmail.com> wrote in message

news:1186736722.061536.310300@x35g2000prf.googlegroups.com...

> On 9 Aug., 23:15, "Paul Randall" <paulr...@cableone.net> wrote:

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

 

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.


×
×
  • Create New...