How to loop through parameters in batch file?

The following example shows how to loop through parameters in batch file.

c:> TYPE script.bat
@ECHO OFF
:TOP

IF (%1) == () GOTO END
ECHO %1

SHIFT
GOTO TOP

:END
ECHO End

Sample Ouptut:
C:\>.\script.bat aaa bbb
aaa
bbb
End

Advertisements