Batch file arguments count

Playing around today with a batch file and needed to work out the total number of arguments that have been passed.

[bat]
SET /A ArgCount=0
for %%a in (%*) do (
SET /A ArgCount+=1
)
echo %ArgCount%
[/bat]

%* Represents all parameters passed to the batch file excluding %0.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.