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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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