When to best trigger smart rule for OCR & move

I’ve written a smart rule script that OCRs PDFs if necessary, renames them according to some standard, and moves them to appropriate database&groups depending on their kind (think different bank accounts, invoices etc.).

This smart rule should process the global inbox when a new PDF is imported there, trivially. But: Occasionally I import stuff in the global inbox on my iPhone or iPad. So I thought, I should have the smart rule triggered by “after synchronisation”, too.

But that results in about a new run of it every five seconds although I’ve set the sync interval to automatic on my Mac and nothing has been added to the inbox at all.

To summarize: What kind of trigger should I select to make sure that documents arriving in my inbox on the Mac either by importing them there or by being sync’ed from another location are passed through the smart rule and the rule is not running more often then necessary? (I know, I could simply set it to “runs once every day” or something, but that’s not very elegant, is it?).

Currently each sync of any database can trigger this. How does your current smart rule look like?

Well, there was no change in any database :wink:

(looks like nothing at all because all the work is done in the script, of course :wink:

Even in that case the automatic sync checks every then and now for changes.

The script would be useful of course then :wink:

I sent you the script by PM. Also, there are some PDF records in the global inbox that are not moved away from the script – they should just remain there as they are. This is intentional. I’m wondering if that might be triggering the execution.

And here’s what I see in the protocol window:

after I added a logMessage call to my internal script. It doesn’t look very systematic to me: sometimes the script is run twice in two seconds, sometimes 20 seconds are passing between execution.

Some more facts: The execution coincides with DT contacting my WebDAV server which is handling sync. Exact same times for WebDAV traffic and the messages in DT’s protocol. And the messages do not happen when I turn sync off.

So apparently “after sync” means something like “when DT contacted the sync server”, at least in the case of WebDAV. But there’s not really any sense in executing a smart rule “after sync” when nothing has been synchronized, is there? And there was no change at all in my case, i.e. DT apparently just wanted to make sure that – well, what? the server is still there? it is still there and there’s nothing to do? I don’t know.

That’s most likely the reason, the rule could e.g. add a flag, label or tag after processing the item and the conditions of the rule should exclude items having this flag, label or tag.

Yep, that’s what I did. It still feels clumsy though. In my mind, after sync should trigger only if something happened during sync. Preferably a file was added or modified.

Hi chrillek, I’m a beginner with DevoThink and also not so familiar with Apple Script and am currently trying to setup a similar automation. Could you please share that script for the automation as a kind of template for my attempts?

BR - AWD

See this thread, please: