Reputation: 816
My code looks like this in .bat file
start /B "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" imacros://run/?m="loop-google-ad-word.iim" -loop 3
timeout /t 120
But problem is I am not able to loop my loop-google-ad-word.iim
script 3 times from batch file it runs just once normally.
I referred http://wiki.imacros.net/Example-Batchfile.bat here and did similarly. Also referred iMacros randomly stops in a loop but it does not loop
Any related suggestions are appreciated. Thanks in advance.
Upvotes: 1
Views: 3866
Reputation: 89
If you use batch script you can construct a code like this for an infinite loop!
@echo off
:Intro
start /B "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" imacros://run/?m="loop-google-ad-word.iim" -loop 3
timeout /t 120
goto Intro
quit
Ok, this uses a simple goto command, hope it works!
Upvotes: 0
Reputation: 701
The easiest way in my opinion to have an .iim Macro loop 3 times after being launched from a .BAT File is to put the following Statement at the beginning of your Macro (+ Adjust '!DATASOURCE_LINE' by 2 or 3 if your Macro uses a Datasource...):
SET !LOOP -1
SET !DATASOURCE_LINE {{!LOOP}}
ADD !DATASOURCE_LINE 2
And your .BAT File will look like this:
start /B "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" imacros://run/?m="loop-google-ad-word.iim"
timeout /t 120
(I use it myself...)
Upvotes: 0
Reputation: 816
The above code helps me to loop batch file so in this loop I also added the code to delete 1st row of csv file from which my imacro reads data, so automatically imacro will get next row data at each loop.
Also No. of times it should loop i have made dynamic depending on the lines in my csv file. So it first counts no. of lines and then passes it to for loop %cnt%
@echo It will count no.of lines in file and pass the count 2for loop
set file=C:\Users\account\Documents\iMacros\adwords-filename.csv
set /a cnt=0
for /f %%a in ('type "%file%"^|find "" /v /c') do set /a cnt=%%a
echo %file% has %cnt% lines
timeout /t 5
@echo Loop starts now-------------------
for /L %%A in (1,1,%cnt%) do (
@echo call macro script
start /B "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" imacros://run/?m="loop-google-ad-word.iim"
timeout /t 60
@echo delete 1st line of csv file at each loop
set "csv=C:\Users\account\Documents\iMacros\adwords-filename.csv"
more +1 "%csv%" >"%csv%.new"
move /y "%csv%.new" "%csv%" >nul
)
Upvotes: 1
Reputation: 14305
What about using the batch file to loop?
for /L %%A in (1,1,3) do (
start /B "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" imacros://run/?m="loop-google-ad-word.iim"
timeout /t 120
)
Upvotes: 1