batch script: loop and labels

688 Views Asked by At

I am trying to make a script (batch in windows) that download 5 text files using wget, and do some operations to each one, so I am thinking to do this with a loop just like this

set i=0
:begin
set /a i=%i%+1
if %i% equ 5 exit
wget ".....file1.txt"
goto operations

:operations
stuff
stuff
goto begin
  • operation consist of getting infromation from the text using grep and sed and saving it to text

well, it should work, but this will take a lot of time, I want the batch to do it in an efficient way, because in this way it will download one (take some time) and will do the opeartions. What I want to do is to make it a multi threaded, I mean to make it do these 5 files (download+operations) simultaneously.

thanks

1

There are 1 best solutions below

2
On BEST ANSWER

If you made the actual process of wget + processing a separate batch file, you can then "start" the batch file which will spawn it as a sub process and continue on in your main batch file eg.

batchfile1.cmd
<do something really long>

batchfile2.cmd

for %%N in (a b c d e f g) do start batchfile1.cmd %%n

you'll end up with a-g running all at the same time - however you cant easily then tell when all have finished.