Automatic updating of indexed files in synced database

I’m using a plain text note taking app (TheArchive, an NValt spinoff) for all my note taking on the Mac.

Up until a week ago, I used to have the notes in a folder in my Dropbox to access them on my iPhone with an iOS note taking app. Because I would prefer end-to-end encryption for my notes, I decided to try out the following setup:

  • move notes folder out of Dropbox
  • index notes folder in a new DT database
  • sync this database with iPhone

Judging from my initial testing, the setup appears to work. One point that I couldn’t figure out though is to when indexing/syncing are triggered on the Mac. Ideally, I would like to not have to open the database or the indexed folder in DT on the Mac regularly, because all reading as well as editing is done in TheArchive and I merely use DT as syncing backend. It seems as if I have to

  • activate DT app on the Mac
  • select the indexed folder
  • then after a little while, I get Dropbox notifications that the sync store got changed

Is there any way I could make this setup work automatically, ideally even if the DT app is not running or the notes database isn’t opened. For example, are there AppleScript commands to trigger indexing and syncing so that I could build a launchd job.

Thanks for your help and suggestions!

Yes, there is an AppleScript command to update indexed items but they will not allow you to do this with DEVONthink or the database closed. You must have both opened. Check out the dictionary in Script Editor. The command is synchronize, noting this is not database syncing.

Thanks for the pointer, Jim! I now wrote a short AppleScript that

  • checks whether DT is running, otherwise launches it
  • opens the respective database
  • re-indexes the folder

This script is executed by Hazel every time the indexed folder that holds my plain text notes changes on disk. That part seems to work great.

I have a few follow-up questions regarding the Dropbox sync:

  • how quickly does DT trigger the Dropbox sync? (it seems to be a few seconds, how is it determined, can one modify it, etc.)
  • is this time the same independent of what service (Dropbox vs. iCloud vs. …) is used to sync?

Furthermore, I ask myself how to best make sure that the other direction also works – i.e., that changes I make on my iPhone are synchronized reliably and quickly to DT on the Mac and the indexed folder. For this, I’d like to know how/when synced file changes to indexed files are applied by DT, i.e.,

  • is the only condition that DT has to be running?
  • does the folder have to be indexed manually/by script after the changes come in via Dropbox sync or are they automatically applied?

Based on that information, I would then add another Hazel rule that monitors the “DEVONthink Packet Sync” folder in Dropbox…

Thanks!