Angel said:
Is there a predefined batch file parameter that gives the number of
command line arguments?
At least Phil "beat" me to this FAQ solution, but here is what I have
@echo off & setlocal enableextensions enabledelayedexpansion
set argc=0
:_loop
if "%~1"=="" goto _next
set /a argc+=1
set argv[!argc!]=%~1
shift
goto _loop
:_next
::
echo argc=%argc%
for /l %%i in (1,1,%argc%) do echo argv[%%i]=!argv[%%i]!
endlocal & goto :EOF
The output might be
C:\_D\BAS>cmdfaq 1 2 3 "4 5"
argc=4
argv[1]=1
argv[2]=2
argv[3]=3
argv[4]=4 5
Note a catch. After you apply the above, you no longer can access
the original parameters. If you need them later in the batch, you
have to store them at the outset of the batch file like in the above.
All the best, Timo