How to Tools->Rebuild DB and Tools->Verify a R with Apple S.

Hi all,

the subject already said all.
I want to do the two things via Apple Script:

Verify and Repair
Rebuild Database

How can I do that?


There is a “verify” command in DEVONthink’s scripting dictionary. View the dictionary in Script Editor for an explanation. For rebuild you would need to write a call to System Events to press that menu item.

This is a case where scripting is overkill. The commands have (or can have) keyboard shortcuts – and an AppleScript is only going to do the same things (press the button) as the shortcut. So to build a debug a script will take far longer than pressing a shortcut.

The more important question though is why do you need a script(s) to do these actions? They are rather rarely used, and usually because of errors. If you are experiencing problems that require frequent verification or rebuilding then maybe it would be more useful to work with Support to get to the root cause and fix it?

Hi korm,

I will try to answer your questions.

  1. I want to use these actions, because I have an export script. Exporting the whole database on a backup media. So it was the idea to do this maintenance actions before.
  2. I also supposed that these actions are rarely used. But I read an article in your blog: … -database/

There is mentioned that the verify shall be run once a week and the rebuild, my interpretation, once a year.

So, back to your post, I would make a rebuild manually and would try to include the verify in my export-script.


No. Rebuild should be only used in case of errors which can’t be repaired, see blog post:

Gotcha. Criss addressed the rebuild question above.

You can run Verify by this

tell application id "DNtp"
	set theDatabase to current database
	set isVerified to verify database theDatabase
end tell

The variable “isVerified” contains the count of errors, or zero if no errors. If “isVerified” contains a non-zero result then you would want to have your script pop open a dialog, or some other means to tell you not to proceed with step two of your action plan.