Smart Rule: Remove Replicant

You could try this script.

If it does what you’re looking for you could try to

This should work, I think. Please try with duplicates.

-- Remove replicants

on run
	tell application id "DNtp" to my performSmartRule(selection as list)
end run

on performSmartRule(theRecords)
	tell application id "DNtp"
		try
			repeat with thisRecord in theRecords
				set thisRecord_Type to (type of thisRecord) as string
				if thisRecord_Type is in {"group", "«constant ****DTgr»"} then
					set thisRecord_Children to (children of thisRecord whose number of replicants > 0)
					set thisRecord_Database_TrashGroup to trash group of (database of thisRecord)
					
					repeat with thisChild in thisRecord_Children
						set thisChild_LocationGroup to location group of thisChild
						if thisChild_LocationGroup ≠ thisRecord then
							move record thisChild from thisRecord to thisRecord_Database_TrashGroup
						end if
					end repeat
					
				end if
			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