Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
List Filenames from Folder Eskimo Excel Programming 1 May 19th 06 08:41 PM
getting filenames from a user selected folder Mitch Excel Programming 3 June 10th 05 04:55 PM
Look for a string in filenames in a folder? FrigidDigit Excel Programming 2 May 24th 05 04:31 PM
Help with a Macro to list all filenames and mod dates in a folder techmoney Excel Programming 3 November 19th 04 09:52 PM
Folder and filenames? Mark[_45_] Excel Programming 6 July 1st 04 03:49 AM


All times are GMT +1. The time now is 03:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"