@echo off
REM This batch file will play with shift command



:loop
echo %1
shift
if %2 == GOTO end
goto loop
:end


exit 0

When I inputted C:\Users\~\Desktop> Shift.bat 1 2 3
I got this

1
2
end was unexpected at this time.

Why do I keep getting "end was unexpected at this time.

Recommended Answers

All 4 Replies

Try this:
if "%2" == "" goto end
It has been a long time since I have written any complex DOS/Windows batch commands, so I may be mistaken... :-)

commented: Thanks for your help it worked +2

Figured it out right before you replied and I did the same thing you said and it worked. Thanks!!

Happy to help! Good luck.

Turning ECHO on might have guided you to the answer. You were testing %2 = empty as null - If tests strings.
But if the wish was to print 1 2 3 then there is no need for %2...
IF "%1" == "" GOTO end
would work. A sprinkling of pauses can help, too.
I hope that made sense.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.