I finally have a Hazel + Apple Script rule to import items into DT3:
tell application "Finder"
set _path to (the POSIX path of theFile as string)
set {_name, _extension} to {name, name extension} of theFile
-- optional: hide extension in Finder
set extension hidden of theFile to true
-- optional: remove extension for DEVONthink displays
set _name to text 1 thru -((count _extension) + 2) of _name
set _extension to "." & _extension
end tell
-- Import the file.
tell application id "DNtp"
set theGroup to get record with uuid "<UUID of group>"
-- choose one option, Index or Import, comment out the other
set theImport to import _path name _name to theGroup
-- set theIndex to indicate _path to theGroup
end tell
What I can’t get to work is a Smart Rule that performs further actions in DT on these newly added items. I have tried On Creation, On Import, On Moving as the Perform the following actions: criteria.
Additionally, is it possible/wise to have smart rules always monitoring the entire database to add/remove a Label depending on whether the TODO tag exists on an item?
I don’t use Smart Rules in a scenario where I’m importing via AppleScript, however if I recall correctly AppleScript import doesn’t trigger Smart Rules. Try adding a line that calls your Smart Rule
@rmschne I came across your PDF (I think) in another thread and I already do your approach; it’s so great and easy with Hazel. I’m looking for “the next step” where I’m trying to minimise the amount of admin I have to do in DT. First place to start is trying to work out how to skip the global inbox when an item has a destination without my deliberate decision.
@pete31 that works! You are awesome! I am terribly n00b with Apple Script but learning. It didn’t occur to me to use it to tell DT to run the rule. This is going to open up a lot of doors.
I think my “done” scenario will be better solved as a keyboard shortcut macro to remove the TODO tag and change label. Next thing to work out.
This article of yours @rmschne is extremely helpful because importing directly in a DEVONthink group via AppleScript inside a Hazel rule does not seem to trigger any of the Smart Rule import options.
Thanks. I also find that interrogating content of incoming files and making filename changes or tagging is simpler in Hazel for my feeble brain than trying to do it with AppleScript.