How to mention %10 and higher?

Issue

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.

Solution

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

Answered By – OJBakker

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published