There is code below that I used to change ".." to ".". For example I have a name of file like "file..pdf" and I would like to have "file.pdf", but It removes all dots. I don't know how to change it:
Function strLegalFileName2(ByVal FName) As String
Dim i As Integer
Const strIllegals = "*&..&*"
strLegalFileName2 = FName
For i = 1 To Len(strIllegals)
strLegalFileName2 = Replace(strLegalFileName2, Mid$(strIllegals, i, 1), ".")
Next i
End Function
Sub LoopThroughFiles2()
Dim FName As Variant
Dim strNew As String
Dim strDir As String
strDir = "path"
FName = Dir(strDir & "*..*")
Do While Len(FName) > 0
strNew = strLegalFileName2(FName)
If StrComp(strNew, FName) <> 0 Then Name (strDir & FName) As (strDir & strNew)
FName = Dir
Loop
End Sub