Link to home
Start Free TrialLog in
Avatar of Luis Diaz
Luis DiazFlag for Colombia

asked on

Windows Batch: open multiple url tabs based on txt file

Hello experts,

I have the following bat file which allows me to open automatically multiple tabs.
I would like to add the following requirement:

@echo off

SET BROWSER=chrome.exe
SET WAIT_TIME=2
START %BROWSER% -new-tab "url"
START %BROWSER% -new-tab "url2”"

Open in new window


Instead of reporting url I would like to loop a url.txt which contains the various urls.
Error checking:
If url.txt file doesn’t exists
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Luis Diaz

ASKER

Thank you Bill, Possible to report URL_LIST variable with an specific path such as "C:\Test"?
Avatar of Bill Prew
Bill Prew

You can use any valid file name.


»bp
That is you just add the path to the variable:
SET URL_LIST=C:\Test\url.txt

Open in new window

Noted. Unable to test it right now. I will test it as soon as I can.
Tested and it works! Thank you very much for your help.
I have a question, if I want to add a comment in url.txt file in front of url  which string or character should I use.

Example
http://url "comment"
http://url2 "comment2

Open in new window


Thank you again for your help.
The way it is set up currently you can't.  It takes the whole line as the URL.

If you wanted you could select a character as the comment start and ignore anything after that (space, pipe, semi colon, etc).  Then a small change to the FOR /F loop would be needed to accommodate that.


»bp
Ok, In that cas what I will do is to comment directly through rem in the bat file. Thank you again for your help. Bill!
Welcome.