How can I create or add a group of Favorites in Internet Explorer?
June 2, 2008 1:15 PM   Subscribe

How can I turn a long list of hyperlinks into either a list of filenames in Windows Explorer or a list of Favorites in Internet Explorer? Say I have 1,000 hyperlinks in a list so it is 1,000 entries long (could be in an Excel file, a Word file, or on a web page). I want to have these 1,000 hyperlinks as Favorites, which seems to be the same as converting them from the content of one file to the file names of 1,000 files. I can manually save each hyperlink as the name of a file, but if there are 1,000, and if they need to be updated every week, that would be a killer. I need an automated solution.
posted by Wagging Dog to Computers & Internet (4 answers total)
An IE Favorite is really just a text file with a .url extension. The content of the file is in the following format:

[Internet Shortcut]
URL=<insert address here>

You could try whipping up a script that takes your list and saves a new favorite file for each of your addresses. Save each file in C:\Documents and Settings\user\favorites with a .url extension.
posted by phrayzee at 2:00 PM on June 2, 2008

You need a name for each site, not just the URL -- it becomes the name of the favorite's file. I don't know how your list is structured, but if you put the URL and the sitename in a comma-delimited textfile, one site per line (like this: sitename,URL) the following script will work.

setlocal enabledelayedexpansion
for /f "tokens=1,2 delims=," %%F in (listofurls.txt) do (
set filename=%%F.url
set URL=%%G
echo [InternetShortcut]> !filename!
echo !URL!>> !filename!

Save as C:\Documents and Settings\Wagging Dog\Favorites\makefavorites.bat, save your list of URLs as listofurls.txt (in the same directory), and run the .bat file.
posted by harkin banks at 3:09 PM on June 2, 2008

Oh yeah -- this breaks with site names or URLs containing commas. Use with caution.
posted by harkin banks at 3:12 PM on June 2, 2008

Use Excel; in this example I'm using 2003.

Put all of your URLs onto Sheet1, with no empty spaces in between any URLs. Hit ALT-F11, double-click on "Sheet1" from the left-hand side, and paste the code below into the blank code window. You now have a macro called "create_favorites" that you can save within the spreadsheet and run at any time.

You may have to set macro security to medium within Excel (Tools > Macro > Security) and will be prompted to enable macros whenever you open the spreadsheet.

MefiMail if you have any questions; this is mostly re-used code but I'd like to see it serve your needs! My whitespace was lost and I didn't feel like messing with it, but the code runs fine copied and pasted from here.

This code cleans up the resulting filename because many characters in a URL are not valid within a filename.

Private Sub create_favorites()

Dim myURL As String
Dim myPath As String

'You can change this line below, but by default the items drop into your favorites folder
'i.e. myPath = "C:\Temp"

myPath = Environ("USERPROFILE") & "\Favorites"

Dim counter As Integer
counter = 1
myURL = Sheet1.Cells(counter, 1)
If Len(Trim(myURL)) = 0 Then Exit Do 'bail out once you hit a blank
Open myPath & "\" & clean_filename(myURL) & ".url" For Output As #1
Print #1, "[InternetShortcut]"
Print #1, "URL="; myURL
Close #1
counter = counter + 1
End Sub

Private Function clean_filename(instring As String) As String
instring = Replace(instring, "https://", "")
instring = Replace(instring, "http://", "")

For t = 1 To Len(instring)
Select Case Mid(instring, t, 1)
Case "?", "[", "]", "/", "\", "=", "+", "<>", ":", ";", ", ",", Chr(0) To Chr(31)
clean_filename = clean_filename & "-"
Case Else
clean_filename = clean_filename & Mid(instring, t, 1)
End Select

End Function

posted by aydeejones at 8:01 AM on June 3, 2008

« Older Should I rent an apartment with electric baseboard...   |   Is there an ichthyologist in the house? Newer »
This thread is closed to new comments.