Bookends Devonthink Highlights app workflow

Users asking other users for AppleScripts that work with Bookends.
Post Reply
Zyblorg
Posts: 14
Joined: Mon Mar 04, 2019 11:45 am

Bookends Devonthink Highlights app workflow

Post by Zyblorg »

[Post is updated with a newer/better applescript, supplied by Bluefrog from the Devonthink forum, modified a bit by me -- 12 April 2022]

I thought I would share my workflow with Bookends, Devonthink, and the Highlights app. The aim is to use Devonthink as a sort of ‘hub’ to store my notes on journal articles and books, and to be able to do powerful searches through my Bookends reference data, including the attachments’ text.

You will end up with three linked records in Devonthink, for each Bookends reference:

(1) One with the bibliographical information imported from Bookends for a given reference
(2) One with the pdf attachment for that reference
(3) One with any annotations you have made to the pdf attachment for that reference

Part 1: Bookends – put ‘attachment name’, and ‘annotations record name’, and ‘temporary citation’ into notes field

The key to linking the three records in Devonthink for each reference in Bookends is to put the name of the attachment record and the name of the annotations record (which you will make later) into the notes field of your Bookends reference. When you import (or re-import) the reference into Devonthink, these two names will be in the rtf section of the record, because the import includes the notes field.

I have a script at the end of this post to put those two names in the notes field. I name my annotations record “[pdf name] Annotations”. Obviously, you can use whatever convention you want, but modify the Applescript below to reflect that change.

For good measure, I have included as well the Bookends temporary citation format so that, when it gets into Devonthink you can cut and paste this into your document without having to go back to Bookends (note that this format doesn’t have to be exact, it just has to have enough for Bookends to recognise it in a scan -- so I’ve included author, publication year, and reference id).

(Note that if you already have your Bookends references in Devonthink, you can still do this, as long as you haven’t added stuff to the rtf main ‘window’, so to speak. You would have to reimport your references, and when you re-import, the rtf is rewritten, so that added stuff will be lost. However, any custom metadata you added to the reference will be preserved. For this reason, it’s best to set up in Bookends what you want to go in that Devonthink rtf, rather than fiddling with it later. And in any case, most people will want to do reimports from time to time, as they add new reference to their Bookends library).

One you have the record of type (1) in Devonthink, those two names you added to the notes field will act as automatic links to any Devonthink record with the same names, if you have WikiLinks turned on. So turn it on, if you haven’t already.

Part 2: Devonthink – index your Bookends attachments folder; add custom metadata fields

In Devonthink, perform an Import/References from Bookends and choose all references (or whichever subset you want). This creates the references of type (1). (Note that if you are good with Applescript and want to write your own instead of using Devonthink’s own, or find another script does a better import, you can import more metadata into your record (1) than Devonthink currently does. Devonthink doesn’t get it all. Just make sure it includes the notes field for the autolinking to work).

Then also index your Bookends attachment folder. This creates the references of type (2). Don’t add the pdfs to Devonthink, just index the folder. The pdfs are parsed by Devonthink, so they are searchable by Devonthink (assuming you’ve OCRd any that need it). The Devonthink record type (1) with the bibliographical information automatically has a link to the pdf record of type (2), because the pdf record’s name is in the rtf of record (1). And because Devonthink detects links and puts them in the ‘links’ tab of the Document tab of the Inspector, the link is effectively two-way.

In Devonthink I have also made custom metadata for my articles and books. I’ve found the best place to fill all that out is in the bibliographical record of type (1), because its name is the most informative. So I can make smart groups based on the metadata, and the items show up as author and title, rather than just lastname and year.

Part 3: Highlights app – markup your PDF and export the annotations to Devonthink

Finally, when I mark up a PDF I use the Highlights app, because it has a good integration with Devonthink. I use yellow highlights for things I notice while reading but don’t want to save. I use orange highlights for things I want to quote into an annotation summary. I use orange anchored notes for my comments about those quotes or about the text in general. Then I sort the annotations by colour, putting orange first. Next, I export the annotations to Devonthink to produce a record of type (3). (The export to Devonthink directly requires a pro subscription to Highlights). I convert the record (3) to rtf format and change its name from the pdf name to “[pdf name] Annotations”.

So now Devonthink record type (3) is my annotations of the pdf, and record (1) automatically links to it, just as it automatically links to record (2), because I’ve put its name there already when I ran the applescript on my Bookends references.

The result:

– Bookends keeps all the references with their bibliographical data.
– I can markup the PDFs in Highlight, and my annotations stay in the PDF itself, so are accessible in any PDF reader
– The PDFs themselves stay in the Bookends pdf folder, so are available to any program, in the cloud, and any modifications are made to the original file
– Devonthink has (1) a record of the bibliographical reference (to which I have added a lot of metadata) so I can do more powerful/tailored searches than I can in Bookends
– Devonthink has (2) a record of the pdf (which I also OCRd), so searches also take the text of the article or book into account
– As I work through the sources and make annotations, Devonthink has (3) a record that contains my own notes on the article or book
– And all three Devonthink records are linked together, and are linked back to the Bookends reference through (1) the record with the bibliographical information
-- Devonthink record (1) also has a copy of the temporary citation, in case I want paste that directly into my document

The Applescript:

This script is based on the one provided by Bluefrog, which is much better than the original one I made myself. I’ve modified it to do separate checks for each of the three things that are to go into the Notes field, and only add those that are missing.

The script works on references that you have selected rather than on the whole library. Obviously you can select the whole library if you wish.

The script modifies the ‘notes’ field. It sets the notes field to whatever was already in it, plus the name of the attachment of the reference minus the .pdf extension (if there is one), plus the name of the attachment followed by the word Annotations, plus the temporary citation.

For example, I have a record whose notes field was

1942
Nicholas P. White.
23 cm.
Includes indexes.

After running the script it is:

1942
Nicholas P. White.
23 cm.
Includes indexes.

White 1976

White 1976 Annotations

{White, F. C., 1976, #54213}


(And if you are total neophyte like me: Open Script editor, paste this in, save it. Then select a reference from Bookends. Go back to Script Editor and press the ‘play’ icon. Check to see if it worked).

tell application "Bookends"
if ((count library windows) = 0) then
display alert "Open a Bookends library."
return
else
set selectedItems to (selected publication items of library window 1)
if selectedItems = {} then
display alert "Please select an item"
return
else
repeat with thisReference in selectedItems -- Process the selected items

set theAttachments to (attachment items of thisReference) -- Check if there are attachments
if theAttachments ≠ {} then -- If so, process them

set referenceCitation to ("{" & author names of thisReference & ", " & publication date string of thisReference & ", #" & id of thisReference & "}") -- Get the reference's citekey

repeat with theAttachment in (theAttachments) -- Process the attachments

set attachmentName to (name of theAttachment) -- Get the attachment's name

set attachmentName to characters 1 thru -5 of attachmentName as string -- strip off the .pdf extension

set referenceNote to (notes of thisReference) -- Cache any existing note content

if referenceNote does not contain (attachmentName & linefeed) then -- Check if the attachment name is in the existing note already -- the linefeed check is to avoid it being triggered by the Annotations name, which includes the attachment name

set notes of thisReference to (referenceNote & linefeed & linefeed & attachmentName) -- Add the attachment name to the notes, preserving existing notes
end if

set referenceNote to (notes of thisReference) -- Cache any existing note content

if referenceNote does not contain (attachmentName & " Annotations") then -- Check if the Annotations name is in the existing note already

set notes of thisReference to (referenceNote & linefeed & linefeed & attachmentName & " Annotations") -- Add the Annotations name to the annotations, preserving existing notes

end if

set referenceNote to (notes of thisReference) -- Cache any existing note content

if referenceNote does not contain referenceCitation then -- Check if the Citation is in the existing note already

set notes of thisReference to (referenceNote & linefeed & linefeed & referenceCitation) -- Add the Citation to the notes, preserving existing notes

end if

end repeat

end if

end repeat

end if
end if
end tell
Last edited by Zyblorg on Tue Apr 12, 2022 3:44 pm, edited 2 times in total.
DrJJWMac
Posts: 345
Joined: Sat Jun 22, 2019 8:04 am
Location: Alabama USA

Re: Bookends Devonthink Highlights app workflow

Post by DrJJWMac »

Just curious.

* Why the trip out to Highlights? Do you prefer its annotation tools over those in Bookends? Do you prefer to keep your PDFs in Bookends "pristine"? Or both?
* Are you doing this all on macOS? Alternatively, are you doing anything on iPadOS?

--
JJW
--
JJW
Zyblorg
Posts: 14
Joined: Mon Mar 04, 2019 11:45 am

Re: Bookends Devonthink Highlights app workflow

Post by Zyblorg »

Hi DrJJWMac,

I just prefer to do my annotations in a dedicated PDF viewer. I like the interface better, so it's a personal preference. I really like how Highlights shows the full text both of highlight annotations and anchored notes along the side. And on the ipad, it's a sort of 'split-screen' view, with annotations taking up the right half of the screen. With an ipad pro, the PDF is still big enough to read, and it really lets me focus on my digestion of the article. Also, as I said in the post, there is a really nice integration of Highlights with Devonthink, so my annotations become searchable in Devonthink as well.

The workflow is on MacOS. Wiki links are not supported in Devonthink to Go. However, I do most of my pdf reading and markup on my iPad, and because the annotations are embedded in the PDF itself, it can be part of the workflow.
Jon
Site Admin
Posts: 10048
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Bookends Devonthink Highlights app workflow

Post by Jon »

Just in case you didn't realize it (or others don't realize it), Bookends also shows the highlighted text and notes along the side, in the note stream.

Jon
Sonny Software
stoic1348
Posts: 5
Joined: Mon Jun 22, 2020 2:33 pm

Re: Bookends Devonthink Highlights app workflow

Post by stoic1348 »

Zyblorg, I sent you a pm...
Post Reply