Last Updated: February 25, 2016
·
2.004K
· ksi

Update URLs in Safari Bookmarks & History

If your internal IT changes links to frequently used websites, you usually have to update your bookmarks. That's one step, but the history won't be affected. To change it all, all you need is a regex:

# close Safari!

cd ~/Library/Safari
cp Bookmarks.plist History.plist ~ # make a backup!!

# convert to readable
plutil -convert xml1 Bookmarks.plist
plutil -convert xml1 History.plist

# change with regex
sed -e 's/our\.old\.url/my\.new\.url/' -i.orig Bookmarks.plist
sed -e 's/our\.old\.url/my\.new\.url/' -i.orig History.plist

# check
diff Bookmarks.plist.orig Bookmarks.plist
diff History.plist.orig History.plist

# if ok, convert back
plutil -convert binary1 Bookmarks.plist
plutil -convert binary1 History.plist

Restart Safari. If something went completely wrong, reinstall your backup files, that's what they're for.

See also: https://gist.github.com/3224919