How to pass parameters to a bat script

batch-file

Excuse my newbie question but I haven't had to touch bat scripts since the days of the autoexec.bat… and that one was even called from the system directly.

So I wonder how I can pass in arguments to my bat script?

For example I want to create n directories with a certain name. I would like to use a construct such as this one:

for %%N in (1 to $arg1$) do mkdir $arg2$-%%N

As a result I would like to have N directories called

  • name-1
  • name-2
  • name-3

… and so on.

Thanks!

Best Answer

it is just %1 %2 ... %n for argument1, argument2, ..., argumentn

see this for example.

The for loop I did like this:

FOR %%a IN ("filename1" "filename2" "filename3") DO something %%a -clean Lib -log errors >> logfilename