Summary
This smart rule, including a short script, effectively grabs the item link of an imported record and places it on the clipboard so that you can paste it in an existing markdown document in the group containing that document.
My need for the rule
I have written before of the delights of diarying (US: joy of journalling) in DEVONthink. I have separate groups for each year of diary entries and each of those groups contains a sub-group called Photos
. When I wish to add a photo to a diary entry (initially imported into a Temp
group) I import it into the relevant Photos
group and then, of course, paste the item link in the diary entry. This rule simply saves me:
- right-clicking on the photo when imported and choosing
Copy Item Link
; - then returning to the
Temp
group containing the relevant diary entry.
It’s not sophisticated but it does save me time (and saves me forgetting to do 1 above when I import the photo!).
Posted deferentially in the hope it might sometime help someone else. (Of course, you’d want to change the name of the watched group and the UUID of the group to wish you return at the end of the script.)
on performSmartRule(theRecords)
tell application id "DNtp"
try
repeat with theRecord in theRecords
set theName to name of theRecord
set theRefURL to reference URL of theRecord
set theLink to "[" & theName & "]" & "(" & theRefURL & ")"
set the clipboard to theLink
display notification "Item link of image added to clipboard" with title "Get item link of imported image"
end repeat
-- Go back to the Temp group
set myGroup to get record with uuid "F3E59383-23EF-4CAB-9912-369CF9CF45CC"
set root of viewer window 1 to myGroup
end try
end tell
end performSmartRule
Stephen