Automatically Update Indexed Items?

I find myself sometimes forgetting to update indexed items before closing DEVONthink on my Mac resulting in less than up-to-date spreadsheets and other documents in DTTG. Is there a script, Smart Rule, or other method to force updating of indexed items when closing DEVONthink?

Thanks for any suggestions…

Are you indexing items in a cloud-synced location, like Dropbox?

Some reside on iCloud drive and some are in the Documents folder on my hard drive.

As noted in the Help, items in cloud-synced locations may require manual updates via File > Update Indexed Items to avoid conflicts with the service’s updates.

Does that square with your situation?

Yes, it does. Are you inferring records linked to local files will update automatically? If so, I have no problem moving the files in question to my hard drive.

The files should be available locally, not stored in the cloud. However updating manually may still be required with cloud synced folders.

Are you syncing your Desktop and Documents to iCloud via macOS’ settings?

I was syncing Desktop and Documents to iCloud before a recent clean install of macOS 11.2.1 and have not selected that option again. I’m now storing only files in iCloud I think I may need when away from home.

Well…I learned something this morning about updating synced items residing in iCloud. If I make a change in an indexed document located in iCloud, that record in DEVONthink will update if I select something else then select the record. This means I could modify the document in iCloud, but the record will not update unless it is selected. If not selected, the record in DTTG will be out of date.

I have created a Keyboard Maestro script to open DEVONthink every night, select File → Update Indexed Items, then close. It appears to do just what I need.

My only question is whether there is some issue I might inadvertently create by running this script unattended. Any thoughts?

1 Like

I don’t see any potential harm as it’s just updating from what the filesystem is reporting.

Thank you, Jim, for your continued excellent support.

You’re very welcome :slight_smile:

I have been using Keyboard Maestro to run that script to update indexed items for a few years now. I configure mine to run when the Mac is idle for 10 minutes and DEVONthink is running.

I find that in order for my macro to run, DEVONthink needs to be the front window. Running the macro while I’m working in a different app is a bit annoying when the DEVONthink window pops up. Have you found a way for the macro to function in the background?

I run an applescript, are you selecting the menu item to perform the update? I attached a screenshot of the KM macro and also the text of the applescript.

-- Update indexed items of all databases
-- Created by Christian Grunenberg on Tue Mar 25 2014.
-- Copyright (c) 2014. All rights reserved.

-- Set to true if indexed items are not only located at the root of the database
property pAllRecords : true

-- set dScope to button returned of (display dialog "Index all records at all levels?" buttons {"Yes", "No", "Cancel"} default button 2 with title "Setting")
-- if dScope = "Yes" then set pAllRecords to true
-- if dScope = "No" then set pAllRecords to false

tell application id "DNtp"
		set theDatabases to databases
		show progress indicator "Updating Indexed Items" steps (count of theDatabases)
		repeat with theDatabase in theDatabases
			step progress indicator (name of theDatabase as string)
			set theRecords to records of theDatabase -- Children of root
			repeat with theRecord in theRecords
				if pAllRecords or theRecord is indexed then
					synchronize record theRecord -- Updates children of theRecord too
				end if
			end repeat
		end repeat
		hide progress indicator
	on error error_message number error_number
		hide progress indicator
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell

Yes, I’m using Select or Show a Menu Item. It does what I need, but as mentioned interrupts whatever I’m working on at the time. I was planning on writing a script to accomplish the same, but just don’t have the time right now.

Thank you so much for sharing your script. It is very much appreciated…

Idle will not work for me, … cannot work out why … tried ensuring is idle but no action. I am trialing indexing at login, (using a big pause because I have a lot going on at login) … that seems to work okay for me, as I can do manual update during day, if I have some need to do this, … of course would not suit everyones circumstances.

What is Keyboard Maestro’s Engine Log telling you? I see the following entry: Execute macro “Update Indexed Items” from trigger The Mac has been Idle for 1 minutes.

Set the delay time to 1 minute, open the Engine Log and clear entries so it will be easier to read.

Thanks for that. Just ran into a bunch of folders that DTP would not re-index.

Found your script, ran it, perfect.