Using Skim with DEVONthink

I’m a little hesitant to post this script for two reasons:

  1. It’s not very robust (no error checking and expects things to be in certain places without checking.)

  2. I don’t have the knowledge or time to improve it right now.

Having said that, this script has been working well for me that last couple of months, helping integrate DTPro and Skim workflows. And perhaps the community here can give feedback or advice to improve it as well.

Skim has a command-line interface tool that will output your notes to txt, rtf, etc. This shell-script takes a path to a skim’d pdf as an argument and outputs the notes as a text file into a folder (~/Documents/Papers/1_Skimnotes). I then keep this folder indexed in DTPro along with my pdfs. I’m using Hazel to monitor my Papers folder and when it detects a change it will run the script on the updated file (if the file has no skim notes, nothing is output.)

Pros

  • access to all of your skim notes in DevonThink (including using them as “see also”)
  • I like the fact that my notes are separate from the pdf itself because often I want to search only those things that I’ve considered important enough to highlight or annotate.
  • the first line of the note file should auto wiki-link to the pdf file

Cons

  • it’s a two-step process: shell script outputs the notes, DT indexes the notes.
  • it probably won’t handle strange characters in the pdf name.
  • many more, I’m sure, but they’re not springing to mind.

Usage

  • Skim should be in your Applications folder. You should have a folder ~/Documents/Papers/1_Skimnotes (or change that line below to reflect where you want the notes to go)

  • paste the code below into a text file, save it as “out_skimnotes” and then chmod it to be executable

  • make sure the script is in your $PATH.

  • in terminal give the script a path to a skim’d pdf, e.g. “out_skimnotes ~/Documents/Papers/Chen2005.pdf”


#!/bin/bash

note=$(/Applications/Skim.app/Contents/SharedSupport/skimnotes get -format text "$1" - )

filename=${1##\/*\/} #removes all the path above the pdf
echo $filename
extension="\.pdf"
citekey=${filename%$extension}

if 
	test -n "$note"
then
	echo $"### $filename ###"$'\n\n'"$note"$'\n\n'------- > ~/Documents/Papers/1_Skimnotes/$citekey".txt"

fi

exit 0

if you can get this working, you can run it on an entire hierarchy of folders using this script:



#!/bin/bash

default_path=~/Documents/Papers/

start_path=$*

echo "##Notes from "${start_path:=$default_path}'##'

find ${start_path:=$default_path} \( -type f -name "*.pdf" \) | xargs -I '{}'  out_skimnotes  {} 

exit 0

Sorry, I know my explanation has been somewhat cursory; maybe others have some better ways of explaining it. (This might belong under “Scripting DT” but since we’re not directly working with DT, I posted under “Tips”).

Best,
Jeff

Thanks for the info, I’ve been trying to find ways to integrate Papers into Devonthink.

Do you integrate your Papers pdf files into devonthink as well?
I’ve been thinking that it would be nice to use devonthink’s web server to access the my articles remotely.

Thanks again for the scripts!

I don’t actually use the program Papers. I’ve had my folder for journal articles named that for years before ‘Papers’ came out. I think it looks like a nice program, but I’m too close to finishing to throw a new tool into my workflow.

My bad, I saw a post dealing with Papers and my mind became dizzy with joy :slight_smile:

Seriously though, you should try it when you get a chance.