Auto-clearing of completed items

The following script is an extension of the “Move to Done” script written by Christian Grunenberg. This version does the exact same thing, but functions as a Smart Group script, so that cleared items from within a particular group get moved to a global “Done” folder whenever the group is visited. I prefer having this automated than having to manually run a script each time.

John


-- Move Contents to Done
-- Created by Christian Grunenberg on Mar Sat 15 2005.
-- Modified to be a Smart Group by John Wiegley on Jan Tue 9 2007.
-- Copyright (c) 2005. All rights reserved.

on moveCompleted(theRecord)
	tell application "DEVONthink Pro"
		set theChildren to children of theRecord
		repeat with theChild in theChildren
			if state of theChild is true and state visibility of theChild is true then
				set theGroup to create location "/Done"
				move record theChild to theGroup
			else
				my moveCompleted(theChild)
			end if
		end repeat
	end tell
end moveCompleted

on triggered(theRecord)
	try
		my moveCompleted(theRecord)
	on error error_message number error_number
		if the error_number is not -128 then
			try
				display alert "DEVONthink Pro" message error_message
			on error number error_number
				if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
			end try
		end if
	end try
end triggered