Last active
April 20, 2025 18:51
-
-
Save echohn/eb8f31165aa288a3d0de115ac11ee543 to your computer and use it in GitHub Desktop.
safari auto backup bookmarks bash script
This file contains hidden or 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 | |
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