How to move overwrite a moved file in target

Hi, I have a file that is updated externally at regular intervals and I want to store it in Devonthink. The file is stored in the ‘/USER_NAME/Library/Application Support/DEVONthink 3/Inbox’, and from there it is automatically moved to the target database. The existing file there should be overwritten / replaced. For this purpose I defined an intelligent rule with a move action. Moving the file works quite well, but the existing file in the target database is not overwritten / replaced, but placed next to it. How can I achieve that the file is replaced in the target?

Welcome @bauchladen

Why don’t you just index the file into the destination database? That avoids having to use the Global Inbox and a smart rule. Also, the file would stay up to date as it’s changed in the filesystem.

I get the file via ftp download. Devonthink is my central file storage, I try to avoid a mixture of external and internal documents.

You can still index the file in the Finder, then overwrite it when you get the download from FTP. This would be the simplest way to accomplish what you’re trying to do.

1 Like

You could add another smart rule that moves every file x which is older than the span of the regular update interval to the trash. Or to a just-in-case-it-might-be-needed backup folder.

Or better: You could add a script which removes file xs at the destination as a first action to the smart rule that moves the new file x.

1 Like

I am new in Devonthink and have no clue what such a script could look like. Is there perhaps a template , or a manufactured solution for this problem?

Select the record and run this script

-- Copy Location and Name

tell application id "DNtp"
	try
		set theSelection to selection of viewer window 1
		if theSelection = {} then error "Nothing selected"
		set theRecord to item 1 of theSelection
		set theLocation to location of theRecord
		set theName to name of theRecord
		set the clipboard to (theLocation & theName) as string
		display notification (theLocation & theName) as string
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell

Then paste the copied location in this script

-- Get record at location and move to trash

tell application id "DNtp"
	try
		set theRecord to get record at ""  in database ""
		move record theRecord to trash group of database of theRecord
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell

See the help or search the forum if you want to use this in a Smart Rule

1 Like

Thank you, I will give it a try :slight_smile: