Avoid duplicate names of notes

I would like to have an option to be warned when I create a new document if another document with the same name already exists. Can this be achieved by script?

There is already a smart rule/group that identifies duplicates in a database. I am sure it would be easy to extend this to beep or do something when you created and saved/synced a duplicate.

I am not looking for duplicates (documents with identical content) but for notes/documents with identical names.

DEVONthink fully supports having documents with the same name so no, there is no built-in mechanism.

Here is a simple AppleScript snippet that may do what you want…

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			set theMatches to (search "filename==" & (filename of theRecord as string))
			if (count theMatches) > 1 then
				set name of theRecord to (theRecord's name without extension & "-" & (count theMatches) as string)
			end if
		end repeat
	end tell
end performSmartRule

thank you, this looks promising. I created it as a smart rule for the event “on renaming” and it seems to work.

You’re welcome.

BTW:
The filename might be different even if the name is identical (and vice versa), therefore using the name is probably what @rainer1957 intended.

1 Like