Discussion:
How to extract bookmarks from Safari Bookmarks.plist?
(too old to reply)
DG
2005-08-17 15:37:07 UTC
Permalink
The new Safari version (in Tiger) seems to use a new binary format for
~/Library/Safari/Bookmarks.plist and not a plain XML file as before. It
can be edited in Property List Editor as a regular XML file, but I
haven't been able to automatically extract bookmarks with previously
working methods, like grep, DOMParser or even an applescript posted at
http://bbs.applescript.net/viewtopic.php?pid=43156

Does anybody know how can I extract bookmarks (URL and title) using
shell commands, applescript or javascript? Maybe even the spotlight
shell command "mdfind" could help, as the spotlight results also
include bookmarks, but I still don't know how to make a query for this.

Thanks
Elden Fenison
2005-08-17 22:40:05 UTC
Permalink
Post by DG
Does anybody know how can I extract bookmarks (URL and title) using
shell commands, applescript or javascript? Maybe even the spotlight
shell command "mdfind" could help, as the spotlight results also
include bookmarks, but I still don't know how to make a query for this.
Perhaps I'm missing something. Have you tried File > Export Bookmarks?
--
-=Elden=-
http://www.moondog.org
John B. Matthews
2005-08-18 01:12:20 UTC
Permalink
Post by DG
The new Safari version (in Tiger) seems to use a new binary format for
~/Library/Safari/Bookmarks.plist and not a plain XML file as before. It
can be edited in Property List Editor as a regular XML file, but I
haven't been able to automatically extract bookmarks with previously
working methods, like grep, DOMParser or even an applescript posted at
http://bbs.applescript.net/viewtopic.php?pid=43156
[...]

/Developer/Applications/Utilities/Property List Editor.app can edit
Bookmarks.plist. It has several "Save As" format options, including
ASCII Property List, which may be more amenable to parsing.
--
John
jmatthews at wright dot edu
www dot wright dot edu/~john.matthews/
DG
2005-08-18 14:32:41 UTC
Permalink
Yes, I know this can be done manually using the methods you mention.
What I need is to extract bookmarks automatically from a widget
(javascript) anytime the user requests it.
John B. Matthews
2005-08-19 05:15:48 UTC
Permalink
Post by DG
Yes, I know this can be done manually using the methods you mention.
What I need is to extract bookmarks automatically from a widget
(javascript) anytime the user requests it.
Sorry, I should have actually read your post before responding:-)

I'm not sure I understand your existing approach, but can you invoke
plutil to convert the binary format to text?
--
John
jmatthews at wright dot edu
www dot wright dot edu/~john.matthews/
DG
2005-08-19 16:30:57 UTC
Permalink
Thanks for your replies. I found a way!

I used spotlight's shell commands:
mdfind "kMDItemKind='Safari bookmark'" to get the bookmark files
spotlight has cached and mdls <bookmark file> combined with grep to
extract individual attributes, like name and url.

I hope this will be useful for somebody else.

Loading...