Skip to content

Instantly share code, notes, and snippets.

@hans
Created May 1, 2018 17:23
Show Gist options
  • Save hans/85de020e38bf8c6b92f7f08becff9bb6 to your computer and use it in GitHub Desktop.
Save hans/85de020e38bf8c6b92f7f08becff9bb6 to your computer and use it in GitHub Desktop.
Embed Skim notes in a collection of PDFs
#!/usr/local/bin/zsh
# In a PDF library with associated Skim notes, automatically embed all
# skim notes in the PDF files.
# I used this to help transition from an OS X + Skim reading environment
# to a Linux reading environment.
# WARNING: This script deletes the Skim files after embedding their contents
# in the PDFs. Make sure you back up your library before using.
ROOT=~/Dropbox/Papers
SKIMNOTES=/Applications/Skim.app/Contents/SharedSupport/skimnotes
SKIMPDF=/Applications/Skim.app/Contents/SharedSupport/skimpdf
############
pushd $ROOT
for skim_file in **/*.skim; do
pdf_file=`echo "$skim_file" | sed s/\.skim$/\.pdf/`
# TODO check PDF exists
# First ensure that the Skim notes are actually stored in the PDF.
$SKIMNOTES set "$pdf_file" "$skim_file"
# Now embed.
$SKIMPDF embed "$pdf_file"
echo "$skim_file"
#rm "$skim_file"
done
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment