I have an indexed folder in which I copy now and then through the Find new documents. On each of these documents I have to perform a smart rule action.
In the past I checked hourly to run this action, but it would be better to run the action each time a file changes in the specific folder (i.e. the document gets replaced or added).
How to Trigger a Smart Rule fo this?
There is no event trigger for this.
Assuming you are syncing the database, you could try an Before Synchronization event trigger. Something like this (obviously with nore useful actions)…
This is a cool idea! Thanks Jim. I will try it out!
You’re welcome. Let me know how it works out.
The On Import event should handle this if the search scope of the smart rule is an indexed group.
The Update group here is indexed.
However, I’m seeing no change after editing the file.
I added a new indexed group from a newly created folder in the Finder then edited the file externally. No change in the label color.
Apply the rule changed the label, but not editing and saving the file.
PS: I just didn’t rename the smart rule here.
Editing doesn’t trigger the “On Import” event but adding new files to the indexed folder matching the conditions should trigger it.
Does this mean I can first delete the file and than re-add it with the changed content and the “On Import” event is triggered?
This should trigger the event.
I now have set up a Smart rule for this, but it does not get triggered when I delete a file this indexed folder and then copy a version back in.
Here a screenshot what the smart rule looks like:
Did you delete the file in the Finder or DEVONthink? Is the copy identical to the deleted version?
All deleting and copying is done by a script on the file system level.
Some of the files copied back in are exactly the same (ePUBs), some are slightly different (PDFs). - In future I will only delete and copy back in files which have changed.
None of the files get the tags from the keywords.
Does Data > Tags > Convert Keywords to Tags add them?
Yes! That’s what I for now always do manually after the folder content got updated.
How does your script look like and how do you execute it?
Well, the script (a python3 program) first calls another tool to create all the files in a temp location, then compares what has changed to the files in the indexed folder and finally copies only the changes (I actual could reach out to
rsync for the second part).
At the moment I execute the script manually in Terminal, but I’m planning to set up a nightly cron job for it.
This might be a timing issue. In this manual scenario it should work:
- Launch DEVONthink 3
- Remove the file from the indexed folder
- Wait 1 or 2 seconds until DEVONthink 3 has updated the indexed group accordingly
- Add the modified file to the indexed folder
But if your script is executed while DEVONthink 3 is not running or if your script is too fast (see step 3), then DEVONthink 3 might not recognize that the file was deleted & readded and sees only a modified file instead.
Interesting. So I separated deletion out into a first step. And afterwards I check the folder in Finder: empty.
Then I waited. And check the folder in DEVONthink: Still full with the documents! (But when I preview a document it now says the document is not available.)
I waited longer. Over night. And the folder appears in DEVONthink 3 still with the documents. Only in the Finder it is still empty.
No wonder the Smart rule doesn’t kick in!
Time to move this over to support?