Automatically Update Indexed Folder(s)

I can’t for the life of me find a script or instructions on how to have Devonthink automatically update indexed folders. I’d like anything I add/delete from these folders to be updated in DT as well. Can someone chime in? Thanks!

“Automatically” is one of those terms that has no commonly-agreed definition, and updating DEVONthink databases without attention might lead to unwanted results. However, with the caveat that if it breaks then its yours, here’s one approach – using Keyboard Maestro.

It’s also easy enough to write a simple script using GUI scripting to press the “Update Indexed Items” button on a schedule, and/or use cron,

FWIW, I like my data too much to trust it to any kind of robotic like the above.

One should definitely be careful with automated actions. However, I often need to make sure that my indexed material is up to date, and at those points it would be handy to have a one-button or scripted solution. Example:

While working along, maybe for days, files in indexed folders get added and/or modified outside of DT. Then I need to pack up for a trip. While in transit, DTTG is my de facto filesystem (I try to do all my work in planes, cabs, airports on my iPad these days, and leave the laptop in the bag). Therefore, I have to get all indexed items up to date before syncing to DTTG.

Currently, I need to go to each database I use, select the “Mobile Sync” Group and use “File>Update Indexed Items”, and then sync to DTTG. I currently use 4 databases, so overall this is not too bad, but I think it would be nice to either do this with a simple command, or have a script execute every 15 minutes or so doing this on a continual basis.

I have one question about the Keyboard Maestro action that Korm posted: Since “Update Indexed Items” acts only on the group currently displayed or on the one selected, this solution would periodically update only the group that happens to be selected or displayed. Is that correct? In that sense, this would not be that useful, and outright arbitrary.

I figure that I would have to write a script, that explicitly calls up all databases one by one, and selects all top-level groups and then calls the “Update Indexed Items” command. Or am I missing something?

Even if this can be scripted, it might not be a bad idea to include a “Update indexed items in all open databases” capability within DT, even though I admit that this might lead to menu item overflow, as other users might have other requests for hardcoded items.

You would add commands to the macro to go to the top group, select all (i.e., select all groups), then run the update, and then deselect all.

Thanks, Korm, as always you are back with insights in no time. Thinking about this some more, I realize that a periodic execution of the script would not be good, as the GUI scripting would have to manipulate the windows of DT, which could interfere with ongoing work. So ideally, this would be an action to be started manually, e.g. before synching.

As this script has to make its way through the databases, something generic like the above Keyboard Maestro GUI actions would not be enough. As far as I can see, the database names have to be hardcoded. I haven’t figured out yet how to open or activate databases via AppleScript. I’ll have to figure that out. Apart from that, the structure would be:

tell Devonthink2 to open db1
do all the GUI scripting

tell Devonthink2 to open db2
do the GUI scripting again

and so on.

By the way, for the purpose of GUI scripting, what character is that arrow pointing northwest (left-up) in the shortcut for the menu item “Go > Top Group”? I’ve never seen this before.

The northwest arrow is the “home” key. So ⌥⌘↖︎ is “option-command-home” – on a MacBook without that key it is “fn-option-command-left arrow” – which is a PITA to remember. It’s simpler, IMO, to get rid of goofy keystrokes on a laptop by remapping them in System Preferences > Keyboard.

I have written my first DT Applescript to implement a method to update indexed folders in all my databases in one swoop. I’m not sure if this is exactly what the OP wanted to do, so I’ll open a new article.