Does this work for you?
Sub Test()
Dim i%, j%, iFound%, iProcessed%
Dim n$, x$, files$, s$, sFrom$, sTo$, sPath$
Dim a
sPath = "C:\" 'change accordingly
If Right(sPath, 1) <> "\" Then sPath = sPath & "\"
files = Dir(sPath & "*.xlsx")
Do While files <> vbNullString
j = 0: n = ""
If Left(files, 19) Like "####-##-## ##.##.##" Then
x = Left(files, 10)
Do While InStr(s, sPath & x & n & ".xlsx|") > 0
j = j + 1
n = "(" & j & ")"
Loop
s = s & sPath & files & "|" & sPath & x & n & ".xlsx" & "||"
End If
files = Dir
Loop
If Len(s) Then
s = Left(s, Len(s) - 2)
a = Split(s, "||")
iFound = UBound(a) + 1
For i = 0 To UBound(a)
sFrom = Left(a(i), InStr(a(i), "|") - 1)
sTo = Mid(a(i), InStr(a(i), "|") + 1, Len(a(i)))
If sFrom <> sTo Then
iProcessed = iProcessed + 1
Name sFrom As sTo
End If
DoEvents
Next
End If
MsgBox "Finished." & vbNewLine & iFound & " files found" & vbNewLine & iProcessed & " files processed", vbInformation
End Sub
Bookmarks