Find duplicate files (RexEx) windows

Share your advanced PureBasic knowledge/code with the community.
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Find duplicate files (RexEx) windows

Post by Zebuddi123 »

Hi to All If you find you have duplicate copies of files (windows) with "(1)".zip etc where window appends (*) to the file name. here is a small proc to find them and return a linkedlist with the filename or path&filename

Code: Select all

ProcedureDLL Find_DupFiles(List Source_filelist.s(),rettype.b) ; Source_filelist.s() - Initial filelist  ,  rettype.b - 0=filename, 1= path&filename 
Global NewList dupList.s()
regex.i = CreateRegularExpression(#PB_Any, "\([1-9]+\)")
If CreateRegularExpression(0, "\([1-9]+\)")
	Protected Dim Result$(0),filename.s
		ForEach Source_Filelist.s()
			filename.s=GetFilePart(Source_filelist())
			NbFound.i = ExtractRegularExpression(0 , filename.s , Result$() )
			For k= 0 To NbFound-1
				AddElement(dupList())
				If rettype=0
					dupList()=filename.s
				Else
					dupList()=Source_filelist.s()
				EndIf
			Next
		Next
	EndIf	
EndProcedure


Zebuddi. :)
malleo, caput, bang. Ego, comprehendunt in tempore