Append Comments and Tags as Text in Devonthink Pro Office

Feb 23, 2017 |

(2017-04-03: Script has been Updated by Christian Grunenberg himself! The incredible user support is one of the best selling points for DevonThink.)

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 "DNtp"
try
set theSelection to the selection
set theWindow to missing value
set {od, text item delimiters of AppleScript} to {text item delimiters of AppleScript, ", "}

repeat with theRecord in theSelection
if type of theRecord is rtf or type of theRecord is rtfd then
set theTab to open tab for record theRecord in theWindow
set theWindow to think window of theTab

set theTags to tags of theRecord as string -- tags
set theComment to comment of theRecord as string -- comment

set theTab to open tab for record theRecord in theWindow
set current tab of theWindow to theTab -- Rich text scripting needs a visible document
tell text of theTab to make new paragraph with data (return & return & "Tags: " & theTags & return & "Source: " & theComment) at end
save theTab
end if
end repeat

set text item delimiters of AppleScript to od
if theWindow is not missing value then close theWindow
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.