Last active
November 23, 2022 07:54
-
-
Save hvalls/e07ba7839da6403a7d4f997b30f3da8f to your computer and use it in GitHub Desktop.
Add Safari bookmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd /Users/{user}/Library/Safari | |
while IFS='#' read -r title url | |
do | |
/usr/libexec/PlistBuddy Bookmarks.plist -c "Add :Children:1:Children:0 dict" | |
/usr/libexec/PlistBuddy Bookmarks.plist -c "Add :Children:1:Children:0:URIDictionary dict" | |
/usr/libexec/PlistBuddy Bookmarks.plist -c "Add :Children:1:Children:0:URIDictionary:title string ${title}" | |
/usr/libexec/PlistBuddy Bookmarks.plist -c "Add :Children:1:Children:0:URLString string ${url}" | |
/usr/libexec/PlistBuddy Bookmarks.plist -c "Add :Children:1:Children:0:WebBookmarkType string WebBookmarkTypeLeaf" | |
done < "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, Thank U for sharing this script ;)
Why are U using a loop ? Only the commands 'PlistBuddy' did the trick for me. For example :
/usr/libexec/PlistBuddy $HOME//Library/Safari/Bookmarks.plist -c "Add :Children:1:Children:0 dict"