script to delete without confirming dialog

Hi everybody,

I am new to DTP and to this forum. I am still exploring and learning … (to post in the right forum for example)

While importing and reorganizing a huge database from FileMaker into DTP I got annoyed by the confirmation dialog each time when I deleted a record. As there was no way to suppress it, I wrote a little AppleScript. After reading some forum posts, I guess others might be interested as well.

Warning: I am no AppleScript Guru. Use at your own risk, do backups and please comment if you know more :wink:

The script deletes the selected records and all its instances without questions. To prevent data loss in case of unintended use, it exports each record first to the OS X user trash before deleting it (in emergency case: open the trash, re-import the file and have a tea).

using terms from application "DEVONthink Pro"
	tell application "DEVONthink Pro"
		try
			set theSelection to the selection
			repeat with each in theSelection
				export record each to "~/.Trash/"
				delete record each
			end repeat
		end try
	end tell
end using terms from

Save the script into ~/Library/Application Support/DevonThink Pro/
If you want a shortcut name the file “Movedelete___cmd-Option-ctrl-D.scpt” or somthing like it. Refresh the script menu from within DTP and use at your like.

Johannes

Here is a version of my delete-Script that only deletes the selected instance of a record (leaving its replicates untouched):

using terms from application "DEVONthink Pro"
	tell application "DEVONthink Pro"
		try
			set theSelection to the selection
			set TheGroup to current group
			repeat with each in theSelection
				export record each to "~/.Trash/"
				delete record each in TheGroup
			end repeat
		end try
	end tell
end using terms from

While testing I discovered to glitches:

  1. it will not export empty records to the trash (so you might loose the name of the empty record in case you run the script on the wrong record)
  2. it does not work with replicated groups (it does not delete them)
    I don’t know why, but both are no issue for me (but you have been warned).

Johannes

1 Like