Toggling Indexed State of Selected Records

For some reason, I seem to be deindexing and reindexing indexed items in my databases frequently, and I get tired of clicking around to locate the contextual menu’s “Move into Database” / “Move to External Folder”. And because the commands are in the contextual menu, I cannot use a shortcut or KeyboardMaestro.

So I wrote my own command and inserted this script into the Toolbar. This command will toggle the indexed state of anything that’s either indexed itself or is the child of an indexed folder.

(* Utlity for insertion in DEVONthink 2.x Toolbar 
to toggle indexed status of selected records
20160929.1 korm


use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application id "DNtp"
	set theSelection to the selection
	set c_count to 0
	set d_count to 0
	repeat with thisItem in theSelection
		if thisItem is indexed then
			consolidate record thisItem
			set c_count to c_count + 1
			deconsolidate record thisItem
			set d_count to d_count + 1
		end if
	end repeat
	display alert (c_count as text) & " items moved into database and " & (d_count as text) & " items moved to external location(s)"
end tell

Use as-is and be warned that if it destroys your data, well, then it does.

To put a script into the Toolbar, compile the script and save it (as .scpt) to ~/Library/Application Support/DEVONthink Pro 2/Scripts/Toolbar. Quit DEVONthink, then restart DEVONthink and open View > Customize Toolbar…. Scroll to the bottom of all the commands and your script will appear near the end of the list. You can drag that into the Toolbar and click “Done”. You can assign personal icons to script files if you want. More than half of my Toolbar in DEVONthink is custom commands that provide features like this – and I use my own commands more than DEVONthink’s toolbar commands. I find this technique a cool aspect of DEVONthink.

Agreed. I use my own Toolbar script many times daily.