Taking notes in Devonthink

Short post as I have several research projects that need to finish up before school starts in two weeks.

With help from some code on the DT forum (and my programming wife), I finally managed to come up with a smooth workflow for taking notes. I have literally 1000s of PDFs that I need to take notes on – a quote here, a paragraph there, my disapproval noted elsewhere. DT comes with an Annotation script that will create a new document (linked back to the original) that you can then take notes in. I don’t use it because (as far as I can tell) you can only have one Annotation document for each PDF. Since I am a member of the Cult of The One (Thought, One Note), that won’t work for me.

So as I would come across a salient point in a PDF, I’d do the following:

  1. Copy Page Link for the page of interest
  2. Create a new RTF
  3. Name the file with a summary of the point being made
  4. Tab to the Spotlight Comment and type/paste the citation info (even though I still use tabs for provenance info, I always include the cite info in the comments)
  5. Jump to the body of the RTF to type ‘###’
  6. Select this ### string
  7. Add a Link from that ### back to the original PDF page. It’s always good to have original (co)ntext at hand.
  8. Then start typing my notes.

Needless to say, this takes many steps – I made it a bit shorter with macros, but not short enough.

It wasn’t too long before I decided to figure out if there was a way to script all (or some) of this – this is especially worthwhile since the Add Link command is rather fussy at times. While having my ever-suffering wife tweak a similar script for an hour or so (dead-end, unfortunately), I pretended to make myself useful by searching on the DT forum for some relevant keywords. I soon found this code (New RTF doc from selected text and URL to PDF), which allows you to select text in a PDF and create a new RTF to take notes in, with the URL property of that RTF file linked back to the page of the original PDF. We added a prompt to title the new RTF (since I want my titles to have substantive meaning), to copy the PDF file name to the Spotlight Comment (since I’m reading an original PDF whose file name is not coincidentally the title of the work), and to open the RTF right beside the PDF, for easy transcribing.

I assign a key shortcut and it works like a charm, pasting the selected text into a new RTF. Now I can keep the original PDF open in one window, automatically create another RTF with a link and the required metadata, and send it to whichever group I want. The tweaked code (at the bottom of the forum thread) also opens the new RTF so you can transcribe or take longer notes as needed. Close it when you’re done, then go back to reading the original PDF, creating another note when needed.

Original PDF and selected text with URL link in RTF

Original PDF and selected text with URL link in RTF

But I’m not just recycling somebody else’s code to justify a blog post. This script is great for PDFs that have text, such as what you download from JSTOR or can OCR. But I also have 1000s of PDFs (manuscripts, newspapers, 17C treatises…) that have no underlying text at all because the text quality is horrible – and frankly those are far more deserving of notes. Yet the existing code insists on selected text, or so it seemed. As I became increasingly frustrated with my incompetence as a code-whisperer, wishing I knew how to replace the codespeak “select some text” with “Copy Page Link”, I fought back my rising rage (I wouldn’t make a good programmer) and decided to just cheat. I hypothesized that if I can’t select text (because there’s none to select), maybe I’ll just select the whole page (not in the thumbnail sidebar) and see if it works. And it does! Sends you right back to the page in question, in fact.

The results:

Original PDF and RTF note side-by-side

Original PDF and RTF note side-by-side

So you can use the same code to select a whole image page (drag anywhere on the page, or just Command-A). It won’t paste the image into the RTF, but who cares: you have the link back to the original, and I want to automate steps 1-7 anyway.

Gnarly, dude.

In the process I learned that RTFs have a URL property – in the above image, the blue link in the RTF window right above the style ribbon. I knew bookmarks had them, but bookmarks seemed somewhat useless to me since you can’t add any text. So not only have I saved myself half-a-dozen steps for each note, but using the URL property also has the advantage of avoiding my workaround, which was to type some non-alphanumeric characters, like ###, in the body (so they wouldn’t screw up the AI), select those characters and then Add a Link back to the original PDF page (via Copy Page Link). Of course the URL property only works for the entire RTF; yet another reason to stay on the straight-and-narrow path of One Thought One Note-dness.

So now I just need to figure out how to paste the summary file name into the body of the RTF (so the AI can do its thang), and I’ll be all set. Good times.


Tags: ,

6 responses to “Taking notes in Devonthink”

  1. jostwald says :

    Figured out how to add the filename to the body content.
    Where you create the record, the rich text should say:
    rich text: theName & ”
    ” & theText.
    [You need the to literally add a carriage return to separate the name from the selected text.]

    • jostwald says :

      If one is tempted to combine various notes from multiple PDFs into a single document, there’s some script on another thread in the DT forum: QuoteHighlight&Annotate

      Another way to take notes (without opening the RTF note file for additional note-taking) can be found in the following threads:
      and http://forum.devontechnologies.com/viewtopic.php?f=2&t=19432
      (for a Keyboard Maestro version).

      DT needs to push these out to the users, or at least provide a few common usage scenario templates and let users choose (power users will always be able to tweak to their heart’s content). The simple dump-and-serarch, dump-and-autoclassify, and dump-entire-sources-into-specific-groups strategies are straightforward enough, and are probably used by those with little facility in Applescript or Keyboard Maestro. But DT can be so much more useful for researchers who want fine detail. This could be as simple as: “Want notecards? Try the notecard template! And then combine it with either the make-index-document-from-lots-of-notes script, or duplicate them all into a Project group and manually sort!”
      Alternatively there could be a different note-taking approach: “Want to compose as you read? Try the write-as-you-read template!”
      And let’s not forget the need for custom metadata. And sorting by multiple columns in 3-pane view. It’s getting much much better, but I gotta have that metadata. To take just one recent example: I came across a letter from Marlborough to Townshend explaining why the garrison of Tournai was taken prisoner. In addition to the defenders’ lack of supplies, he also mentioned “and because of what has happened.” God I hate that. So now I need to retrace all their previous correspondence, hoping I can find an earlier letter which will illuminate exactly what this “happening” was. It might be the fact that several hundred Irish and Scots soldiers deserted from the besieging army into the town and fought for the garrison, but I can’t be sure. And with so many pieces of info to keep track of from the siege, and for each letter (date of letter, publication author, publication title, publication date, archive location, author, recipient….), we need separate metadata fields for Author and Recipient.

    • Josh Guthman says :

      I’m new to DTPO, and your posts have been extraordinarily helpful. But when I run the above Applescript I don’t get the option to add the filename. Instead I get shunted immediately to a HUD in which I can simply choose the group the new note will go into. I’m pretty sure I’m messing up when I’ve tried to add the carriage-return text to the script in the script editor. Perhaps you can post the whole script here? Many thanks.

      • jostwald says :

        Not sure if this code will paste properly, but here goes:
        -- Save selected text as RTF
        -- Experimental: 20120829 revised Use at your own risk. Loss of data is your risk.
        --Open RTF added by korm 20140818 by korm
        --See http://forum.devontechnologies.com/viewtopic.php?f=20&t=15875
        -- Select some text in a document in DTPO
        -- Script creates an RTF whose URL is a link that page of that document
        -- Does not open the document with the text highlighted
        -- When clicked in DT, opens the document in a new window (open in tabs seems not work)
        -- the default new file name is the same as the source file; a default prefix and/or suffix can be defined here

        --Additional modifications (prompt for file name, add PDF file name to Spotlight Comment) added 20140818 by ostwaldj.
        --Additional modification (add Provenance tag from orig PDF to new RTF) added 20140918 by ostwaldj.

        property suffix : ""
        property prefix : ""
        property askName : true

        tell application id "com.devon-technologies.thinkpro2"

        set theSelection to selection
        if theSelection is {} then
        error "Please Select Something"
        end if

        --display dialog "Enter file name:"
        --copy the result to
        repeat with thisItem in theSelection

        set theText to selected text of think window 1

        if theText is {} then
        error "Select some text"
        end if

        set theTags to tags of thisItem

        set theName to prefix & name of thisItem & suffix
        set theComment to name of thisItem
        if askName then
        set theName to the text returned of (display dialog "File name" default answer theName)
        end if

        if the current page of think window 1 ≠ -1 then
        set thePage to "?page=" & ((the current page of think window 1) as string)
        end if

        set theUrl to reference URL of thisItem & thePage
        -- if a hardcoded destination is desired, change the following line
        set theDocument to create record with {name:theName, type:rtf, URL:theUrl, rich text:theName & "
        " & theText, comment:theComment, tags:theTags} in display group selector
        open window for record theDocument
        end repeat
        end tell

  2. Josh Guthman says :

    Thank you! Works perfectly.

  3. leon says :

    This is a great script. Thank you! The one by forum user “korm”,the one that produces a formatted rtf file and is here http://forum.devontechnologies.com/viewtopic.php?f=20&t=18885, is also interesting. It could make the title of the note bold! I may ransack that script to already apply some formatting to the RTF document. But (as I said) this is already super helpful.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: