![]() |
Changing filenames in a folder
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 |
Changing filenames in a folder
Change folder name as required. Sub changeToXML() Set fs = CreateObject("Scripting.FileSystemObject") Folder = "c:\temp" FName = Dir(Folder & "\" & "*.XML") Do While FName < "" OldName = Folder & "\" & FName 'take old anem remove extension NewName = Left(OldName, InStrRev(OldName, ".")) 'add xls NewName = NewName & "xls" fs.MoveFile OlName, NewName FName = Dir() Loop End Sub -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=151886 Microsoft Office Help |
Changing filenames in a folder
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 --------------- Jacob Skaria "Pawan" wrote: 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 |
Changing filenames in a folder
Thanks Jacob.. It worked! :)
"Jacob Skaria" wrote: 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 --------------- Jacob Skaria "Pawan" wrote: 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 |
All times are GMT +1. The time now is 03:46 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com