Use the shift
command if you want to work with more 9 parameters.
(actually more than 10 parameters if you count the %0
parameter)
You can [...] use the shift command to create a batch file that can accept more than 10 batch parameters. If you specify more than 10 parameters on the command line, those that appear after the tenth (%9) will be shifted one at a time into %9.
You can either use a loop, store the variables before shifting, or do it quick like this:
@echo off
CALL:LABEL "one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten" "eleven" "twelve"
PAUSE
GOTO:EOF
:LABEL
:: print arguments 1-9
echo %1
echo %2
echo %3
echo %4
echo %5
echo %6
echo %7
echo %8
echo %9
:: print arguments 10-11
shift
shift
echo %8
echo %9
:: print argument 13
shift
echo %9
You can replace the shift commands with a loop in case you have many arguments. The following for loop executes shift
nine times, so that %1
will be the tenth argument.
@for /L %%i in (0,1,8) do shift
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…