Skip to content

Instantly share code, notes, and snippets.

@ky0on
Last active November 1, 2023 06:14
Show Gist options
  • Save ky0on/3a2c54d6c5b9263b1f33cb4e6452e18a to your computer and use it in GitHub Desktop.
Save ky0on/3a2c54d6c5b9263b1f33cb4e6452e18a to your computer and use it in GitHub Desktop.
Backup pdf annotations edited with skim.app
#!/bin/bash
tmp='/tmp/tmp.skim'
find . -type f -regex ".*\.pdf" | while IFS= read -r org; do
dst=$(echo "$org" | sed 's/\.pdf$/.skim/')
if skimnotes test "${org}"; then
if [ -e "${dst}" ]; then
# If .skim already exists
skimnotes get "${org}" ${tmp}
if ! diff -q "${tmp}" "${dst}" >/dev/null; then
# Update .skim only if it is different
mv "${tmp}" "${dst}"
echo "${org}" "(updated)"
fi
else
# If .skim does not exist
skimnotes get "${org}" "${dst}"
echo "${org}" "(new)"
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment