Script to automate URL opening in multiple tabs in Firefox or Opera from a text file

半城伤御伤魂 提交于 2019-12-22 00:56:18

问题


I have a text file with lots of links-each line has a link (i.e the separator is '\n'). i want to write a script so that each link opens in a different tab in Firefox or Internet explorer. How can I do this? I'm on Windows 7


回答1:


Create a text file called whatever.bat and put it on your desktop. edit the file and enter:

set "fileList="
FOR /F "usebackq delims==" %%i IN ("C:\Documents and Settings\mdevine\Desktop\urls.txt") DO call set "fileList=%%fileList%% %%i"
start firefox %fileList%

close and save

double click on it

Note: C:\Documents and Settings\mdevine\Desktop\urls.txt is a text file that contains the following:

http://www.rte.ie
http://www.python.org
http://www.bbc.co.uk
http://www.google.com



回答2:


The solution that worked for me is:

set "fileList="
FOR /F "usebackq delims=," %%i IN ("C:\Documents and Settings\xwell\Desktop\urls.txt") DO (
start %%i
)

Four changes I made:

  1. I set the delimiter to a comma - delims=,
  2. Put a comma between each URL in my text file
  3. And put the for loop function in brackets
  4. Changed the start function. This uses the default browser, though you could specify it as per the above example

So, the text file urls.txt looks like:

http://www.rte.ie,
http://www.python.org,
http://www.bbc.co.uk,
http://www.google.com



回答3:


@iceman, @amadain:

refining @amadains solution: the "line continuation character" in batch files is ^, so iceman should change his text files accordingly (add a ^ at the end of each line) and put "start firefox ^" at the beginning of the file . Don't know max length of command line string, though.



来源:https://stackoverflow.com/questions/3752133/script-to-automate-url-opening-in-multiple-tabs-in-firefox-or-opera-from-a-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!