HI,
Multiple commands for a batch file in a for loop?
Is this possible to do?
Regards,
HI,
Multiple commands for a batch file in a for loop?
Is this possible to do?
Regards,
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.
You could try using the ampserand...
FOR something DO command1 & command2 & command3
but I really don't like doing that in loops or IF statements. Instead, use parens.
For something DO (
command1
command2
command3
)
NOTE: the parens should be used in the exact syntax above - I'm fairly certain trying
FOR something Do (something & something & something)
won't work, nor will
IF something (something & something & something) ELSE (something & something & Something)
(Haven't tested either of the above, but paren use in batch files can be picky - they should always work if you do them the way I first demonstrated).
It can be done by creating different kind of bat file and then calling them one by one. I had seen certain script which workfine in that way. What you need to do is creat a multiple bat file like1.bat, 2.bat, 3.bat, etc. Then create a another script and call them one by one and loop if you want to run that file back again. In this way you can add multiple files inside a single script. This works fine, check properly that you are not missed any code.
I found a another way by which you can run multiple file from the run file. It is right that you need to bifurcate the script in different files. Then you can run that in the form task. For example schtasks /run /tun first task schtasks /run /tun second task, etc. Try this out and run them all once. I hope this script can help you to some extent. There are number of complications involved building up multi command loop script.
Bookmarks