C-Command Software Forum

Skim file management scripts

Attached are four EF applescripts (tested with OS 10.6) to help the Skim-EF-Dropbox workflow and, more generally, to help make consistent the various formats in which one might have saved Skim pdf files – pdfd bundles, pdf wth embedded notes, pdf with notes in extended attributes (i.e., using a normal Skim save).pdfd_to_pdf
pdf_embed-to-pdf
pdf_w_annotations-to-pdf_embed
pdf_w_annotations-to-pdfd

The first three help extend the workflow to iOS (or other) apps that read pdf files but not pdfd bundles.

A suggested workflow would be to

  1. Run the first two scripts on all library records to convert all pdfd bundles and pdf files with embedded notes to regular Skim pdf files.
  2. Select all pdfs and append an “unread” tag; and
  3. Run the third script on all records to embed the notes and remove the “unread” tag from annotated pdfs and only those pdfs. This way only those those pdfs that were annotated would be considered “read”. (Note: If there is a Skim .notes file for a pdf that only has embedded notes, that will bring up a dialog.)

Thereafter, when annotating a pdf in Skim, make sure to embed the changes using the third script (or Skim:File:Export:PDF With Embedded Notes to the original location). Similarly, when annotating the pdf using iOS (or other) tools, make sure to embed the changes.

The key caveat in using the third script is that some Skim annotations may be modified or lost when embedded in the PDF – see all mentions of “embed” on http://sourceforge.net/apps/mediawiki/skim-app/index.php?title=FAQ. In particular, an anchored note appears only as an image, and the text is lost. You should test such issues by round-tripping your annotated pdfs. To do so, 1) embed the notes, 2) close the file, 3) reopen, and 4) File:Convert Notes. Identify all changes (color, borders, editability, etc.) on all your annotation types (highlight, text note, etc.). If the results are satisfactory, open and annotate the pdf in your iOS (or other) app, save, and reopen in Skim and see how the new annotations appear.

The fourth script converts only those pdf files that have annotations in extended attributes to pdfd bundles. So, if one wants to use pdfd bundles only for those files that have annotations, one can run the first and fourth scripts.

Credits: All four scripts were derived from http://c-command.com/scripts/eaglefiler/pdf-to-pdfd. The “do shell” test in pdf_w_annotations-to-pdf_ and pdf_w_annotations-to-pdfd is based on bash code from Christiaan Hofman, and adapted to Applescript with help from Alan Smith.

humanengr

[see follow-on posts for updated scripts]

[further updated to v.03 to reflect change of EF “update checksum” command to synchronous for speed improvement]

Attached is a significantly faster set of AppleScripts to convert between pdf formats: pdf-to-pdfd (i.e., pdf bundle), pdf-to-pdf-embed, pdfd-to-pdf, and pdf-embed-to-pdf:

  • The pdf-to-pdfd and pdf-to-pdf-embed scripts convert pdfs only if they have Skim notes (i.e., notes as extended attributes). Both these scripts add an “annot” tag to indicate the pdf has annotations. (The scripts can also remove “unread” tags from annotated pdfs – see the “adjustMetadata” routine in each script.)
  • The pdfd-to-pdf and pdf-embed-to-pdf scripts leave tags untouched. (This behavior can also be changed in the adjustMetadata routines.)
  • All scripts include Growl progress notifications. (Notification frequency can be adjusted in the scripts. See the System Preferences:Growl pane to adjust stickyness, style, opacity, etc. for the Skim Format Converter application.) If Growl is not on, completion is indicated by “All done” and vocal notice.
  • EF will stop the script if a conversion generates a pdf with pdf content that matches a file already in the library. (EF does not check Skim notes.) If you want to keep multiple versions as regular pdfs with different Skim notes, check EF’s “Allow duplicates” pref. Otherwise, delete the unwanted file.
  • Outside of EF libraries, one can use the shell scripts I posted on the &forum_name=skim-app-users"]Skim mailing list](http://sourceforge.net/mailarchive/forum.php?thread_name=p0624060fcb0b6ec54160%40[192.168.0.102).[/li]

Also attached is a script to add an “annot” tag to each pdf with Skim notes. (This will not tag pdf bundles or pdfs where all notes are embedded.)

[see follow-on posts for updated scripts]

Two more scripts to simplify Skim file management
Here are the 4 EF scripts (embed, unembed, bundle, unbundle) discussed above, updated for compatibility with Growl 2.x.

And here are two Skim scripts to further simplify (un)embedding of Skim-annotated files.

You can assign <cmd>w to the Skim “embed” script (in say, Fastscripts) and <cmd><shift> w to Skim:File:Close (using System Preferences:Keyboard:Keyboard Shortcuts:Application Shortcuts). That way, <cmd>w will embed while <cmd><shift>w will save Skim notes as extended attributes (the normal Skim save).

(The Skim scripts have an underscore in their names: “pdf-to-pdf_embed” and “pdf_embed-to-pdf” for embed and unembed; the corresponding EF scripts are “pdf-to-pdf-embed” and “pdf-embed-to-pdf”.)

and a script to add an “!_annot” TAG To annotated PDF files
The attached script adds an “!_annot” tag to each selected pdf file that contains annotations – whether or not the annotations were embedded.

This is quicker than running the EF unembed and embed scripts in the preceding post to add a tag; the new script leaves the file as it was and just adds a tag.

My practice is to use the Skim embed script (pdf-to-pdf_embed) linked in the preceding post (with the <cmd>w shortcut assigned as indicated) and then periodically use the script attached below on “Recently Modified” records to add the tag.

Notes:

  • Neither the “annot” script below or the EF “embed” script in the prior post removes “!_annot” tags from pdf files no longer containing annotations.
  • The script below does not add tags to Skim pdfd files.

add-annot-tag-to-annotated-pdf.scpt.zip (8.24 KB)