Changing filenames in a folder

  • Thread starter Thread starter Pawan
  • Start date Start date
P

Pawan

Hello

have a folder with several files with different extensions. I want to
change exensions of ".cnf.xml" files to ".xls". I want to do this in excel
macro as I need to work on these files then. Is there any way to achieve this?

Thank you

Regards,
prm
 
Try the below

Sub Macro()
Dim strFile As String, strFolder As String
strFolder = "c:\"
strFile = Dir(strFolder & "*.cnf.xml", vbNormal)
Do While strFile <> ""
Name strFolder & strFile As strFolder & Replace(strFile, ".cnf.xml", ".xls")
strFile = Dir
Loop
End Sub

If this post helps click Yes
 
Thanks Jacob.. It worked! :)

Jacob Skaria said:
Try the below

Sub Macro()
Dim strFile As String, strFolder As String
strFolder = "c:\"
strFile = Dir(strFolder & "*.cnf.xml", vbNormal)
Do While strFile <> ""
Name strFolder & strFile As strFolder & Replace(strFile, ".cnf.xml", ".xls")
strFile = Dir
Loop
End Sub

If this post helps click Yes
 
Back
Top