Merge two Safari bookmark files together

Jul 28, '03 09:10:00AM

Contributed by: georgegraphics

So you know that the Safari bookmarks are kept in ~/Library -> Safari -> Bookmarks.plist. And if you move machines, you can always move the file to the new machine. But what if you want to merge the two bookmark lists? Well, there's the .Mac sync option - but quite a few folks don't have the day-to-day need or money for that. So what do you do? The following requires some knowledge of XML ...

[robg adds: I haven't tested this one, so if you're going to do so, make sure you back up your Bookmarks file first!]

First, back up the Bookmark list on the destination machine. Now boot up Safari on that machine, and add new folder in the left pane of the bookmarks. Call it something easy, and leave it at the end. Then quit Safari, and open the bookmarks list in a text editor. Go right to the end of the file, and find the lines that look like the following:


  </array>
  <key>WebBookmarkFileVersion</key>
  <integer>1</integer>
  <key>WebBookmarkType</key>
  <string>WebBookmarkTypeList</string>
  <key>WebBookmarkUUID</key>
  <string>7AEA714C-428F-11D7-BC62-000393864EB4</string>
</dict>
</plist>
The numbers for the WebBookmarkUUID will be different for you. Just above that, you'll find the entry for the folder you created. Entries are of the form:

  <array>
       [The List here is the subfolders/bookmarks]
  </array>
  <key>Title</key>
  <string>ATitle</string>
  <key>WebBookmarkType</key>
  <string>WebBookmarkTypeList</string>
  <key>WebBookmarkUUID</key>
  <string>5EE95354-82C7-11D7-A781-000393864EB4</string>
Now, the empty folder you created will not have an <array> </array> pair. This is where the bookmarks from the old machine will go. You don't want to copy the entire file -- at the top of the source file, make sure you miss of the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Children</key>
Then copy all the way from <array> down to the </array> near the bottom of the file, leaving out the following XML:

  <key>WebBookmarkFileVersion</key>
  <integer>1</integer>
  <key>WebBookmarkType</key>
  <string>WebBookmarkTypeList</string>
  <key>WebBookmarkUUID</key>
  <string>7AEA714C-428F-11D7-BC62-000393864EB4</string>
</dict>
</plist>
Then save the destination bookmark file. A couple more bits to do...

The history and Rendevouz bookmark entries are special proxy entries, which need to be removed. Search for the second occurence of the string Address Book Bookmark Proxy Identifier. This is the occurence you pasted from the source file. The first occurence is the one you want to leave alone. Around this point, there are two XML dictionary entries which are the Address Book and the History. Remove the following code where you found Address Book Bookmark Proxy Identifier:

<dict>
  <key>Title</key>
  <string>Address Book</string>
  <key>WebBookmarkIdentifier</key>
  <string>Address Book Bookmark Proxy Identifier</string>
  <key>WebBookmarkType</key>
  <string>WebBookmarkTypeProxy</string>
  <key>WebBookmarkUUID</key>
  <string>724DB68E-B7B6-11D7-A346-000393864EB4</string>
</dict>
<dict>
  <key>Title</key>
  <string>Rendezvous</string>
  <key>WebBookmarkIdentifier</key>
  <string>Rendezvous Bookmark Proxy Identifier</string>
  <key>WebBookmarkType</key>
  <string>WebBookmarkTypeProxy</string>
  <key>WebBookmarkUUID</key>
  <string>724DBADD-B7B6-11D7-A346-000393864EB4</string>
</dict>
<dict>
  <key>Title</key>
  <string>History</string>
  <key>WebBookmarkIdentifier</key>
  <string>History Bookmark Proxy Identifier</string>
  <key>WebBookmarkType</key>
  <string>WebBookmarkTypeProxy</string>
  <key>WebBookmarkUUID</key>
  <string>724DBCC5-B7B6-11D7-A346-000393864EB4</string>
</dict>
Save the file, boot up Safari and check if it worked. If not, revert to the backup. You did follow that step, right? Finally, I think the WebBookmarkUUID entries are kind of hashed from the entry contents, so you should move the folder you created to somewhere else to cause hashes to be recalculated.

It sounds like quite the exercise to go through, but if you've got a work machine and a home machine with tonnes of collected bookmarks, it is well worth the effort. Very much a shame you can't export the bookmarks as IE format or whatever.

Comments (8)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030716163239425