Go to last moved document

You might want to check this thread, in which @pete31 so kindly provided me with a solution for exactly that problem.

I think I ended up adapting the script a little bit; anyway, this is what I have used for ages (it opens a new window, partially overlaying the original one, at the location of the last moved document, with that document marked):

tell application id "DNtp"
	try
		set currDate to current date
		set theComparisonDate to currDate - 86400
		
		set theDatabases to databases
		repeat with thisDatabase in theDatabases
			set thisDatabasesResults to search "additionDate >" & theComparisonDate in (root of thisDatabase)
			if thisDatabasesResults ≠ {} then
				repeat with i from (count thisDatabasesResults) to 1 by -1
					set theRecord to item i in thisDatabasesResults
					if type of theRecord is not in {group, smart group} and type of parent 1 of theRecord is not feed then
						set thisDatabasesLastAdded to theRecord
						exit repeat
					end if
				end repeat
				try
					if (addition date of thisDatabasesLastAdded) ≥ theComparisonDate then
						set theComparisonDate to (addition date of thisDatabasesLastAdded)
						set globalLastAdded to thisDatabasesLastAdded
					end if
				end try
			end if
		end repeat
		
		if viewer window 1 exists then
			set theBounds to bounds of viewer window 1
			set newWindow to open window for record parent 1 of globalLastAdded
			set bounds of newWindow to {(item 1 of theBounds) + 22, (item 2 of theBounds) + 22, ((item 3 of theBounds)), (item 4 of theBounds)}
		else
			set newWindow to open window for record parent 1 of globalLastAdded
		end if
		
		set selection of newWindow to {globalLastAdded}
		activate
		
	on error error_message number error_number
		if the error_number is not -128 and error_number is not -2753 then
			display alert "DEVONthink 3" & space & error_number message error_message as warning
		end if
	end try
end tell
2 Likes