Smart rules not triggering on Hazel import

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.

What am I missing?

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?

1 Like

I don’t know about the second question.

For the first … I use Hazel to help move stuff into DEVONthink but no Apple Scripts involved.

I wrote up what I do at: Hazel and DEVONthink

Maybe that helps. Perhaps your way can be made to work, but i discovered a different way.

2 Likes

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

perform smart rule name "Name of your Smart Rule"
2 Likes

@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.

Thanks a bunch to you both.

1 Like

Note to self/others: Smart Rules currently don’t sync so this needs to be solved for this set up to work across computers.

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.

That is correct and the reasons have been discussed on the forums, as recently as yesterday.

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.