Applescript to index a folder or file?

I’m sure I’m missing something obvious - how can I use AppleScript to get DT3 to index a file or folder?

What do you mean by “index”? DT3 can index folders – you need something else?

Indicate is what you’re looking for. Check out Script Debugger, there’s a free version.

-- Index files or folders
-- Note to avoid confusion: after moving to trash a indexed path is still in the database.

property allowMultiple : false

tell application id "DNtp"
	try
		set thePaths to {"/Users/username/Desktop/Test/", "/Users/username/Desktop/Test 2/"}
		
		set theDatabase to current database
		set theGroup to incoming group of theDatabase -- The destination group. Uses incoming group or group selector if not specified.		
		
		repeat with thisPath in thePaths
			if (exists record with path thisPath in theDatabase) then
				if allowMultiple = true then
					indicate thisPath to theGroup
				end if
			else
				indicate thisPath to theGroup
			end if
		end repeat
		
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell

Thanks - I see it in the dictionary description but apparently the descriptions aren’t searchable in Script Editor.

Script Debugger is great to search dictionaries :wink: