Whenever I run the script “Update Indexed items of all databases” (which ships with DEVONthink in the “Data” folder), I get the following error message:
DEVONthink got an error: AppleEvent handler failed.
This was working fine in DT3, but not in DT4. Not sure why, but with some help from ChatGPT, I was able to come up with something that works. I hope this works for others, and perhaps it would be good to update the default, if this is not just some idiosyncratic problem with my set up.
-- Set to true if indexed items are not only located at the root of the database
property pAllRecords : false
tell application id "DNtp"
try
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 theRoot to root of theDatabase
set theRecords to children of theRoot
repeat with theRecord in theRecords
if pAllRecords then
if indexed of theRecord is true then
synchronize record theRecord
end if
else
if indexed of theRecord is true and parent of theRecord is theRoot then
synchronize record theRecord
end if
end if
end repeat
end repeat
hide progress indicator
on error error_message number error_number
hide progress indicator
if error_number is not -128 then display alert "DEVONthink" message error_message as warning
end try
end tell