Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Export a subset of Safari's bookmarks Web Browsers
Every so often, I have occasion to share my bookmarks with a co-worker. But often, I only want to share a subset of my bookmarks. I'm sure there are a dozen programs you can download to do this for you, but I felt like writing some Python today. This script is the result of my efforts. Save this script as export_bookmarks or some such, and make it executable (chmod 755 export_bookmarks). Then run it like so:
% export_bookmarks > bookmarks.html
If you wish to export just a subset of your bookmarks, just provide the names of the folders (one or more) containing the bookmarks you wish to export, like this:
% export_bookmarks Python Perl > bookmarks.html
The resulting bookmarks.html file can be imported into Safari (via Import Bookmarks under the Debug menu). Your mileage may vary...
    •    
  • Currently 2.75 / 5
  You rated: 4 / 5 (4 votes cast)
 
[12,154 views]  

Export a subset of Safari's bookmarks | 7 comments | Create New Account
Click here to return to the 'Export a subset of Safari's bookmarks' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Those wacky UNIX-heads
Authored by: designbot on Oct 05, '04 12:53:52PM
Uh, why not, you know… just drag your folders and bookmarks to wherever you want to put them? Am I missing something? Is it somehow easier to compile a script, open a Terminal window, read the names of the folders, and then type them in?

[ Reply to This | # ]
Those wacky UNIX-heads
Authored by: jaysoffian on Oct 05, '04 02:13:32PM

Well, I had no idea you could do that. Doh.

However - the person who needed these bookmarks was using Firefox (under Linux), so I don't think that would have worked.

In any case, this is also useful for creating a web page of my bookmarks, which considering the # of browsers I use on the # of platforms I use, is useful for me. :-)



[ Reply to This | # ]
Export a subset of Safari's bookmarks
Authored by: mjones1040 on Oct 05, '04 12:55:34PM

If you are sharing with another Safari user, you can simply drag the folders you want out on to your desktop. E-mail the folders to your coworker. He/She can drag the ones wanted into the bookmarks pane of their browser. Voila!



[ Reply to This | # ]
Export a subset of Safari's bookmarks
Authored by: koncept on Oct 05, '04 01:39:07PM

Thanks for the Python code... Just starting to learn it and your code was helpful for making things make a bit more sense to me.



[ Reply to This | # ]
Syntax error
Authored by: osxfan57 on Oct 06, '04 02:50:55AM

When I run the script, I get this response in terminal:

File "./export_bookmarks", line 2
import sys, os, types, codecs import plistlib def read_bookmarks():
^
SyntaxError: invalid syntax

What do I need to change? Thanks.

---
iMac 17, OS 10.3



[ Reply to This | # ]
Export a subset of Safari's bookmarks
Authored by: peragrin on Oct 06, '04 10:16:27AM

Mozilla's bookmarks.html can be set to any webpage.

I upload my bookmarks to my homepage. I use it to access them all over the place. Just place a link to the page. If you use frames it makes it easier to get back.

Why because I am on mulitple platforms as well as lcations. I can get my stuff quick and easy.

What's better is that google, and MSN rank that page. and I have gotten emails correcting my links.

---
I thought once I was found but it was only a dream



[ Reply to This | # ]
I understand why you'd want this
Authored by: Miraglia on Jul 29, '05 10:47:32AM
But the code in its current form doesn't work for me. I get the following error:

Traceback (most recent call last):
  File "./export_bookmarks.python", line 56, in ?
    if __name__ == "__main__": main(sys.argv[1:])
  File "./export_bookmarks.python", line 53, in main
    else: filter_bookmarks(read_bookmarks(), [], found=1)
  File "./export_bookmarks.python", line 14, in read_bookmarks
    return plistlib.Plist.fromFile(bookmarks_file)
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac/plistlib.py", line 212, in fromFile
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac/plistlib.py", line 303, in parse
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 8

Cool utility -- hope it's fixable (I don't know any Python, sadly.)

-Eric

[ Reply to This | # ]