Moving documents with annotations

This Smart Rule script moves annotation records to the database of annotated records

Note: The script scope is all databases, the scope you’ve set in the Smart Rule has no effect.

-- Smart Rule - Move annotation record of every database to database of annotated record

-- Note: The script scope is all databases, the scope you've set in the Smart Rule has no effect.

on performSmartRule()
	tell application id "DNtp"
		try
			set theDatabaseResults to contents of every database whose annotation's database ≠ database of it
			
			repeat with thisDatabaseResult in theDatabaseResults
				repeat with thisAnnotatedRecord in (thisDatabaseResult as list)
					move record (annotation of thisAnnotatedRecord) to (annotations group of database of thisAnnotatedRecord)
				end repeat
			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
			return
		end try
	end tell
end performSmartRule

4 Likes