用于从文本文件在 Firefox 或 Opera 的多个选项卡中自动打开 URL 的脚本

发布于 2024-09-24 07:41:21 字数 121 浏览 1 评论 0原文

我有一个包含很多链接的文本文件 - 每行都有一个链接(即分隔符是“\n”)。我想编写一个脚本,以便每个链接在 Firefox 或 Internet Explorer 的不同选项卡中打开。我该怎么做?我使用的是 Windows 7

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

生死何惧 2024-10-01 07:41:21

对我有用的解决方案是:

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

我做了四项更改:

  1. 我将分隔符设置为逗号 - delims=,
  2. 在文本文件中的每个 URL 之间放置一个逗号
  3. 并将 for 循环函数放在括号中
  4. 已更改启动函数。这使用默认浏览器,尽管您可以按照上面的示例指定它

因此,文本文件 urls.txt 如下所示:

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

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
寄风 2024-10-01 07:41:21

创建一个名为whatever.bat 的文本文件并将其放在桌面上。编辑文件并输入:

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%

关闭并保存

双击它

注意:C:\Documents and Settings\mdevine\Desktop\urls.txt 是一个文本文件,包含以下内容:

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

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
夜巴黎 2024-10-01 07:41:21

@iceman、@amadain:

完善@amadains 解决方案:
批处理文件中的“行继续符”是^,因此iceman应该相应地更改他的文本文件(在每行末尾添加一个^)并将“start firefox ^”放在文件的开头。但不知道命令行字符串的最大长度。

@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.

吃不饱 2024-10-01 07:41:21

如果有人正在寻找如何在 Chrome 中执行此操作,这里是解决方案:

@echo off

set URL1= https://www.google.com
set URL2= https://www.youtube.com
set URL3= https://stackoverflow.com

start chrome --new-window "%URL1%" "%URL2%" "%URL3%"

将此代码另存为批处理文件,然后双击即可。

注意=号之前没有空格
当我尝试使用空间时,它对我不起作用

If anyone is looking for how to do this in Chrome, here is the solution :

@echo off

set URL1= https://www.google.com
set URL2= https://www.youtube.com
set URL3= https://stackoverflow.com

start chrome --new-window "%URL1%" "%URL2%" "%URL3%"

Save this code as batch file and just double click.

Note that there is no space before the = sign
It wasn't working for me when i tried with space

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文