Batch Disc indexing

First of all, create and make sure you have open a database called “Disc Catalog” (or edit the script to your desired file name).

I’ll recommend now, disabling the “Create Thumbnails” for all file types in the Media section of DEVONthink’s Preferences. Leaving these on causes DT to slow down during Indexing (hence the Timeout block).

If you have a different version of DT (Personal/Pro/Office) you may also wish to change the application name near the bottom of the script.

If you accidentally start the script after you have mounted the disc your desired to scan, just eject and re-mount. The script looks for new discs that are added to what’s already been mounted.

Click “Cancel” on the dialog box to quit the script’s loop.

I gladly invite features, suggestions, and optimizing any of my code.

I think copyright lines in scripts are tacky, so I release this under whatever is the most up to date GPL.

--Disc Batch Scanner for DevonThink Pro
--  By Mike Cramer III
--     kiodane [at] Google's email service
--     Created on Feb 09, 2010
--         To be considered under the most up to date GPL

	tell application "Finder"
		set OldDisks to name of every disk
		repeat while (count of OldDisks) ≥ (count of (get name of every disk))
			set OldDisks to name of every disk
			display dialog "Please Insert disc to be indexed. Found " & (count of OldDisks) & " disks." buttons {"Cancel"} giving up after 10
			set the button_pressed to the button returned of the result
		end repeat
		set NewDisks to name of every disk
		set FoundDisks to {}
		repeat with AnDisk in NewDisks
			if not (OldDisks contains AnDisk) then set FoundDisks to FoundDisks & AnDisk
		end repeat
		repeat with AnDisk in FoundDisks
			set Path_To_Disk to (POSIX path of (disk AnDisk as alias))
			with timeout of 60 * 60 seconds
				tell application "DEVONthink Pro" to indicate Path_To_Disk to incoming group of database "Disc Catalog"
			end timeout
			eject disk AnDisk
		end repeat
	end tell
end repeat

That’s right for thumbnails created via Quick Look (e.g. web archives, rtf/rtfd etc). or QuickTime (e.g. movies). But thumbnailing PDF documents and images causes almost no additional delay.