Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a list of URLs in a text file, for example,

http://url1
http://url2
http://url3

I wonder how to open them each in one tab in Firefox (or SeaMonkey), without the hassle of creating a new tab, copying into address bar and hitting return for each URL?

My OS is Ubuntu 10.10. Both command line and GUI solutions are welcome.

share|improve this question
add comment

5 Answers 5

You can save the following to a HTML file:

<!doctype html>
<html>
<head>
<title>Open Windows</title>
<script>
function openWindow(){
    var x = document.getElementById('a').value.split('\n');
    for (var i = 0; i < x.length; i++)
        if (x[i].indexOf('.') > 0)
            if (x[i].indexOf('://') < 0)
                window.open('http://'+x[i]);
            else
                window.open(x[i]);
}
</script>
<style>
html, body
{
    height : 99%;
    width  : 99%;
}

textarea
{
    height : 80%;
    width  : 90%;
}
</style>
</head>
<body>
<textarea id="a"></textarea>
<br>
<input type="button" value="Open Windows" onClick="openWindow()">
<input type="button" value="Clear" onClick="document.getElementById('a').value=''">
</body>
</html>

Now load the file in Firefox, copy the list of URLs in the textarea and click Open Windows.

share|improve this answer
    
Hah... I haven't thought 'bout that one! I usually do it with firefox `cat file.txt` (as WakiMiko wrote). Anyway using your way will work on all OS. :D –  tftd Feb 2 '12 at 16:39
1  
Now this is what I call "for the win." +1 for platform independence. Would definitely accept this answer. Supported: SeaMonkey, FireFox, IE, Chrome, Safari, etc...Ubuntu, Windows, Mac, etc. –  Matt Borja Jun 6 '12 at 22:39
    
Technically chrome blocking as pop-ups. But since I need source and I'm running fiddler, you made my day. Thanks a done. –  Jones Apr 8 '13 at 15:12
add comment

A simple

firefox $(cat file.txt)

should suffice. It will pass each link as an argument to the firefox command, as long as every link is separated by whitespace.

share|improve this answer
    
+1. Thanks! That works! I wonder if you happen to know how to do that in SeaMonkey? I tried seamonkey $(cat urls), but only the url in the first line is opened. –  Tim Feb 2 '12 at 17:03
add comment

On windows you can create a batch file (named say, multiurl.bat):

@echo off    
for /F "eol=c tokens=1" %%i in (%1) do "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" %%i

and then run multiurl.bat urls.txt from the command line and it will load the URLS in new tabs if FireFox is already open, or it will run it and then load the URLS.

share|improve this answer
    
You aren't required to create a .bat file to use the for command. –  Oliver Salzburg Feb 2 '12 at 16:25
2  
This is not relevant - the users asks for a solution that will work on Linux machines! –  tftd Feb 2 '12 at 16:37
    
@TheDevil Come on, this answer took longer than three minutes to test and type. I suggest tfitzgerald keeps this answer up, there might be others interested. I sure won't delete my answer for OS X. –  Daniel Beck Feb 2 '12 at 17:20
    
@TheDevil Yes, he edited his question as I was writing my answer. –  tfitzgerald Feb 3 '12 at 1:47
1  
@OliverSalzburg That is correct. But I don't think I said you are required to...but why would you want to type that whole line each time you wanted to do this? That is what scripts are for! –  tfitzgerald Feb 3 '12 at 1:48
show 2 more comments

Open your text file in firefox as

file:///C:/URLTextFile.txt
  1. Select the whole link
  2. Right click on it
  3. Click on "Open Link in new tab"
share|improve this answer
add comment

On Mac OS X, save the following script as openurls.sh, run chmod +x openurls.sh in Terminal, and then type ./openurls.sh from the same directory.

#!/usr/bin/env bash

while read line ; do
    open -a Firefox "$line"
done < "/path/to/file-with-urls.txt"
share|improve this answer
    
+1. Thanks! Do you also know how to do that for SeaMonkey instead of Firefox? –  Tim Feb 2 '12 at 16:12
    
@Tim I don't have SeaMonkey to test it. Also, I'm afraid this script opens windows instead of tabs, sorry about that. –  Daniel Beck Feb 2 '12 at 16:16
1  
This can easily be fixed with changing some settings in Firefox. Go to Edit->Preferences->Tabs and select "Open new window in new tab instead" :) –  tftd Feb 2 '12 at 16:41
    
@TheDevil Thanks! I guess it's obvious I only use FF for answering questions on SU. –  Daniel Beck Feb 2 '12 at 16:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.