Advertisement
themacdweeb

Replace One Safari Bookmark.sh

Oct 16th, 2013
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.21 KB | None | 0 0
  1. #!/bin/sh
  2. # Copyright © 2013, David Koff for the J. Paul Getty Trust
  3.  
  4. # ---------------------------------------------------------------------------
  5. # 1. assign variables to discover users with UID > 500
  6. # 2. back-up those accounts' safari bookmarks & test for that backup
  7. # 3. convert the bookmark plist, find & change one bookmark, then resave bookmarks file
  8. # ---------------------------------------------------------------------------
  9.  
  10. # part 1: assign variables
  11. over500=`dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }'`
  12.  
  13. # ---------------------------------------------------------------------------
  14. # 2. cycle through users & backup each user's bookmarks
  15. # 3. convert, modify & then resave the bookmarks file
  16. # ---------------------------------------------------------------------------
  17. for i in $over500
  18. do
  19.     cd /Users/$i/Library/Safari
  20.     zip BookmarksBackup.zip Bookmarks.plist
  21.     echo "backup of bookmarks SUCCESSFUL for the $i account."
  22.     plutil -convert xml1 Bookmarks.plist #convert from binary to XML
  23.     perl -pi -e 's/http:\/\/go\/workforce/http:\/\/go.getty.edu\/workforcelite/g' Bookmarks.plist
  24.     plutil -convert binary1 Bookmarks.plist #convert back to binary
  25. done
  26. open -a Safari.app
  27. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement