I've had a jolly good search through the world of google to find a similar problem to mine, but I can't find any examples of people doing things outside of their FOR /F loops and so I am resigned to creating a new thread.
I am using a FOR /F loop to execute a Ruby Gem once per line it finds in a reference file, which it does perfectly. The problem is, when it has finished scrolling through its reference file and executed the Ruby Gem the correct amount of times, it will not complete anything else in the .CMD file outside of the FOR /F loop.
Here is my .CMD code:
FOR /F "tokens=1,2,3 delims=," %%a in (c:\cygwin\usr\work\easy.lst) do (
c:\ruby191\bin\scrapitalist website -u http://www.website.com/%%a/%%c/%%b.html -o C:\cygwin\usr\autobets\work\%%b_%%c.easy
)
copy c:\cygwin\usr\work\*.easy c:\cygwin\usr\autobets\work\easy.imp
The easy.lst file has two lines of data in it.
The loop works fine, executing the Ruby Gem and creating *.easy files as output, however, the COPY command never executes. I can replace the copy with an ECHO, or in fact anything, but it will not execute.
I cannot see what I am missing from my FOR /F syntax - any ideas peeps?
Thanks
Represents a replaceable parameter. Use a single percent sign ( % ) to carry out the for command at the command prompt. Use double percent signs ( %% ) to carry out the for command within a batch file.
FOR /F processing of a text file consists of reading the file, one line of text at a time and then breaking the line up into individual items of data called 'tokens'. The DO command is then executed with the parameter(s) set to the token(s) found.
To stop this infinite loop, press Ctrl + C and then press y and then Enter.
I suppose that scrapitalist
is a batch file itself, therefore it stops the batch file, but as the FOR-loop is cached, it work to the end.
To solve this you only need a single call
as prefix.
FOR /F "tokens=1,2,3 delims=," %%a in (c:\cygwin\usr\work\easy.lst) do (
call c:\ruby191\bin\scrapitalist website -u http://www.website.com/%%a/%%c/%%b.html -o C:\cygwin\usr\autobets\work\%%b_%%c.easy
)
copy c:\cygwin\usr\work\*.easy c:\cygwin\usr\autobets\work\easy.imp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With