0

I have a csv file with several urls. I want to use a batch file to open these urls in firefox but not every url at once, since there are several hundreds of them.

Therefore I have made the following script which should stop adding tabs to firefox after 3 urls:

@echo off
set counturl=1
for /f "delims=" %%a in (urllist.csv) do (
    start firefox -new-tab "%%a"
    timeout 5
    set /a counturl+=1
    echo  %counturl%
    if %counturl% GTR 2  (goto :pause)
)
:pause
echo end loop
    pause

However, this fails because somehow the counturl variable isn't updated. So the loop keeps on running.

In another attempt I got the counturl variable to update, but now only the first url is shown in firefox.

@echo off
set counturl=1
:loop
for /f "delims=" %%a in (urllist.csv) do (
    start firefox -new-tab "%%a"
    timeout 5
    if %counturl% GTR 3  (goto :pause) else (set /a counturl+=1)
    echo  %counturl%
    goto :loop
REM    taskkill /f /im firefox.exe
)
:pause
echo end loop
    pause

There is probably some simple thing I am overlooking. Thanks for the assistance in making this work.

Freeze
  • 217
  • 5
  • 12

0 Answers0