Computing.Net > Forums > Windows XP > Multiple do commands in for loop

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Multiple do commands in for loop

Reply to Message Icon

Name: Roger (by lwmo)
Date: March 25, 2008 at 13:18:44 Pacific
OS: XP
CPU/Ram: P4/2GB
Comment:

I need to run multiple DO commands in my FOR /F loop.

for /f "options" %%a in (fileset.txt) do (fc /b /c %source%\%%d if not %errorlevel%==0 call error.bat)

The file compare happens but then I get a line with FC: Invalid Switch. The loop continues to file compare other files. Problem is I cannot check the errorlevel of the file compare and pop up an error.bat file if the file compare found that the files were not the same.

RP



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: March 25, 2008 at 13:51:03 Pacific
Reply:

You need to code ONE command per line and checking errorlevel has to be coded as below, i.e.

for /f "options" %%a in (fileset.txt) do (
fc /b /c %source%\%%d
if errorlevel 1 call error.bat)

or use the conecting operator ||

for /f "options" %%a in (fileset.txt) do (
fc /b /c %source%\%%d || call error.bat)

Anyway your FC command lacks the second file to be compared.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Multiple do commands in for loop

Executing Dos commands in C++ www.computing.net/answers/windows-xp/executing-dos-commands-in-c/68404.html

FTP through DOS Command in XP www.computing.net/answers/windows-xp/ftp-through-dos-command-in-xp/147082.html

Dos Commands in Windows Xp www.computing.net/answers/windows-xp/dos-commands-in-windows-xp/113893.html