Append Comments and Tags as Text in Devonthink Pro Office

Feb 23, 2017 |

I make and sort my reading notes in Devonthink Pro Office, but I write in Scrivener. The comments and tags do not transfer between the programs, unfortunately. Because I use tags for data analysis and comments for provenance information, this presents a real problem when writing. I can’t tell what category the data fits in or what the source was.

To avoid cross-referencing Devonthink for each citation, I created a script that appends the tags and comments as text. Each document in the selection gets this information added at the end. Thus, it is readily available in each note in Scrivener.

I’m a hack-programmer, so this probably isn’t the most elegant solution. But it works, and that’s all I care about.

Copy and paste the below text into a new Applescript file:

-- Append Tags and Comment as Text
-- Created by John Mickey on 2017-02-23
-- Based on a script created by Christian Grunenberg on Aug Tue 16 2011.

tell application id "com.devon-technologies.thinkpro2"
set theSelection to the selection
set createRecord to true

repeat with theRecord in theSelection
set theTab to open tab for record theRecord

set theWindow to think window 1
set {od, text item delimiters of AppleScript} to {text item delimiters of AppleScript, ", "}
set theTags to tags of theRecord as string -- tags
set theComment to comment of theRecord as string -- comment
-- set text of theWindow to "" -- Mark as modified
set createRecord to false
if type of theRecord is rtf or type of theRecord is rtfd then
open tab for record theRecord in theWindow
set current tab of theWindow to tab -1 of theWindow

tell text of theWindow
set insertName to true
tell text of tab 1 of theWindow to make new paragraph with data ("Tags {" & theTags & ", Source: " & theComment & "}") at end
end tell

end if
save theWindow
close theWindow
end repeat
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try
end tell

Posted in: Uncategorized

Comments are closed.