This is an agent i use, it looks up a view with the first column sorted by the value you are looking for duplicates in (in my case company names) and places all duplicates into a folder named…Duplicates
hth
Sub Initialize
Dim Session As New NotesSession
Set db=Session.CurrentDatabase
Set view=db.GetView("(company)")
Dim Doc As NotesDocument
Dim LastDoc As NotesDocument
Set Doc=view.GetFirstDocument
LastCompany$=""
AllCount%=0
DupCount%=0
While Not (doc Is Nothing)
ThisCompany$=doc.ColumnValues(0)
AllCount%=AllCount%+1
If ThisCompany$=LastCompany$ Then
Call doc.PutInFolder("Duplicates")
Call LastDoc.PutInFolder("Duplicates")
DupCount%=DupCount%+1
Print "Detected duplicate for "+doc.Code(0)+" - Total so far: ";DupCount%;" out of ";AllCount%
Else
LastCompany$=ThisCompany$
End If
Set LastDoc=doc
Set doc=view.GetNextDocument(LastDoc)
Wend
Messagebox Str$(DupCount%)+" duplicates detected from"+Str$(AllCount%)+" documents and placed in the Duplicates folder.",64,"InTouch"