How to Trigger a Smart Rule on File Changes in an Indexed Folder

This should trigger the event.

1 Like

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:

Screen Shot 2021-01-06 at 10.36.33 am

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:

  1. Launch DEVONthink 3
  2. Remove the file from the indexed folder
  3. Wait 1 or 2 seconds until DEVONthink 3 has updated the indexed group accordingly
  4. 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?

?
Missing or not available?

The preview comes up with a thumbnail of the document and underneath is the text “File missing:” with the path to the indexed document.

Are you replacing the file with one of the same name?

I have deleted the files (so not the folder they were in). But this delete is not picked up by DT3.

This was not always like this: I do remember, a few days ago (when I started to tackle indexing the documents in this external folder) deletions and changes to the files in the folder were picked up by DT3, but now they are not noticed.

Why are you deleting the files?
And what kind of files are they?

I delete them first because afterwards - after the pause Christian suggested (so that DT3 can catch up) - new files with possibly changed keywords are copied in.

Files are ePUBS and PDFs.

Why don’t you just use the Before Synchronization event trigger I originally suggested?

It works regardless if you’re updating a file or replacing it.

That’s now not the main problem. The main problem is that DT3 does not update the indexed folder.

I might start a new topic for this to keep things clearer.

Where is the indexed folder in the Finder?

See DT3 does not update an indexed folder when the folder’s content changes for a continuation.