That script is super helpful! I changed it a tad and thought I’d share. I like to use Typora as my markdown editor, so I made the script open the annotation file in Typora if there was an annotation file. Also, I don’t use keyboardmaestro so I put the script in the scripts folder and used the app CustomShortcuts to give it a keyboard shortcut. Now whenever I have a record selected in DT and hit the keybinding it opens the annotation file in Typora. Super awesome!
tell application id "DNtp"
try
repeat with theRecord in (selection as list)
if (exists annotation of theRecord) then
set annot to get annotation of theRecord
set annotRecord to get record with uuid (get uuid of annot)
set thisPath to path of annotRecord
do shell script "open -a typora " & quoted form of thisPath
else
set rec_name to get name of theRecord
display alert "Document has no annotation" message rec_name
end if
end repeat
on error error_message number error_number
if the error_number is not -128 then
display alert "DEVONthink" message error_message as warning
end if
end try
end tell