0

I'm trying to make a batch file I call from another batch file, but the variables don't work after 9, and while I could just insert the code for the file I call, that is highly impractical and inelegant.

If I were to use %* it does read all variables but I need them to be separate, not as a group

here's the code to demonstrate the issue:

call temp.bat a b c d e f g h i j k l m n o p q r s t e u v w x y z
pause
exit

and the called file:

echo %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 etc.
echo %*
exit /b

I have already tried a trailing %, hexadecimal, and quoting it, none of them worked.

aschipfl
  • 33,626
  • 12
  • 54
  • 99

1 Answers1

2

Use the internal command SHIFT repeatedly to access the parameters beyond %9. See SHIFT /? for details on how to use this.

OJBakker
  • 602
  • 1
  • 5
  • 6
  • Ok, that works. Is there a way to shift multiple in one go, or do I just need to run the command multiple times? – JustenDouma Sep 24 '21 at 08:57
  • @justendouma, see `shift /?`, that’s what `/?` is for – elzooilogico Sep 24 '21 at 09:27
  • 1
    I did, but it doesn't mention anything about being able (or not being able) to shift multiple times. – JustenDouma Sep 24 '21 at 09:59
  • @JustenDouma what conclusion would be reasonable to draw from the help output not showing a switch for such an action? are you anticipating super secret switches that do exactly what you hope? I suggest you [see here](https://stackoverflow.com/a/30003809/12343998) – T3RR0R Sep 24 '21 at 11:56
  • wouldn't be the first time something isn't mentioned in the /? – JustenDouma Sep 24 '21 at 12:07
  • Yes it would be. Also, if you need more than 10 arguments, your code needs to be rewritten. – SomethingDark Sep 24 '21 at 12:15