Dealing with * in parameters examples:
@ECHO OFF
SETLOCAL DISABLEDELAYEDEXPANSION
CALL testLIMIT.bat 3 4 2 1 2 3 4 5 3 2 1 2 3 4 5 6 5 4 3 2 1 2 3 4 5 6 7 6 5 4 3 2 1 A Star * is Born twice * now
ECHO HOME
Pause
exit
@ECHO OFF
SETLOCAL EnableDelayedExpansion
REM :: Used to define the Array Index values and Range
set _I=0
REM :: The Core piece in recieving Large numbers of Parameters.
REM :: Processes all Parameters. Tested to over 2500 Parameters.
Set StarTest=0
FOR %%a in (%*) DO (
IF EXIST "%%~a" Call :StarTest
IF NOT EXIST "%%~a" (
CALL Set /a _I+=1
CALL Set "arg[!_I!]=%%a"
CALL Set StarTest=0
)
)
REM :: Loops through the Array to display Parameter Values.
FOR /L %%a in (1,1,!_I!) DO (
ECHO !arg[%%a]!
)
echo %_I% Arguments received.
Pause
GOTO :EOF
:StarTest
IF %StarTest% GTR 0 GOTO :EOF
Set /a StarTest+=1
Set /a _I+=1
Set "arg[!_I!]=*"
GOTO :EOF
Processing parameters with Shift is Entirely Unneccesary, not to mention messy.
The following approach, Similar to Marcels Answer, will process Exceptionally large numbers of parameters without any requirement to know how many Arguments will be recieved.
It uses A basic For loop with the * wildcard to process all tokens and Assigns them to an Array, also giving a Value to how many arguments the File recieved to enable processing.
@ECHO OFF
SETLOCAL EnableDelayedExpansion
REM :: Used to define the Array Index values and Range
set _I=0
REM :: The Core piece in recieving Large numbers of Parameters.
REM :: Processes all Parameters. Tested to over 2500 Parameters.
FOR %%a in (%*) DO (
Set /a _I+=1
Set "arg[!_I!]=%%a"
)
REM :: Loops through the Array to display Parameter Values. Modify as needed to Process Parameters.
FOR /L %%a in (1,1,!_I!) DO (
ECHO !arg[%%a]!
)
echo %_I% Arguments received.
Pause
GOTO :EOF