Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
safari auto backup bookmarks bash script
#!/bin/bash
usage(){
echo "USAGE: bash $0 OUTPUT_PATH"
exit 1
}
[[ $# -ne 1 ]] && usage
backup_path=$1
this_dir=$(cd "$(dirname "$0")"; pwd)
today=$(date +%Y-%m-%d)
temp_file="/tmp/${today}-bookmarks.xml"
plutil -convert xml1 -o $temp_file ~/Library/Safari/Bookmarks.plist
xsltproc $this_dir/Bookmarks.xslt $temp_file | sed 's/<\/DT>//g' > $backup_path/$today-bookmarks.html
rm -f $temp_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.