Automatc OCR and export - rule doesn't start when import from AppleScript

Hi there,

I have created an intelligent rule in DT3 that monitors the general input.
If PDFs with a Tag “NeedOCR” are imported there, OCR starts and exports the files to a directory on my Mac.
This works well if I start the import in the Finder with the right mouse button under Services.

Now I have installed the following AppleScript in Hazel, which automates this transfer to DT3:

tell application id "DNtp"
	set thisGroup to get record at "/Inbox"
	import theFile to thisGroup
end tell

The import runs correctly so far. The Tag is also set and with the intelligent rule I also see that there is a 1 there.
However, the rule is not executed automatically.

where is the difference between the two methods?

Is there something missing in the script?

Welcome @soc007

That is the correct behavior. AppleScript doesn’t trigger smart rules.

You have to add the command perform smart rule too.

That’s nice. Thanks.

The import command imports all files in the directory, but the perform command for the smart rule only for one file in the inbox.
have already tried repeat and other things.

but unfortunately can’t do it.
how can I call up the smart rule and it processes the entire inbox?

Could you please post the current script and a screenshot of the current smart rule?

tell application id "DNtp"
	set thisGroup to incoming group
	import theFile to thisGroup
	perform smart rule name "OCR and export for Hazel"
end tell

A screenshot of the rule would be useful too.

Is the smart rule exactly named OCR and export for Hazel?

yes, the first document is also processed with the rule. But only the first document and unfortunately not all others.

Please post the smart rule.

I’ll do it tomorrow because I’m currently not at home.
thank you in advance for your support.

No worries and you’re welcome.

No tipp what is wrong?

Remove the “Abbrechen”-Action from the smart rule.

Unfortunately, that didn’t work either.
As before, I import two documents via script and the rule is still only executed for the first document.
The other document remains in the inbox.

Does importing multiple files without Hazel (e.g. via drag & drop instead) work as expected?

Yes, it works as expected. All documents go through the rule.