Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Macro to rename Excel files in a folder

Hi-

I have a folder with 500 or so Excel files and they all start with a
specific date. For Example: 20070119_File1.xls

Does anyone have a macro that will loop through the folder and rename
just the date portion of the file? Example: I want to rename all of
the files that start with 20070119 to start with 20061231 but still
contain the rest of the filename.

Take:

20070119_File1.xls

and rename it:

20061231_File1.xls

Any help is appreciated!

Thanks,
Chris

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Macro to rename Excel files in a folder

You could modify this to work within a DIR loop using mid oldname and mid
newname

Sub movefile()
OldName = "C:\oldfolderl\oldname.xls"
NewName = "C:\newfolder\newname.xls"
Name OldName As NewName
End Sub
Sub anotherfindfiles1() 'It does work.
Application.ScreenUpdating = False
Dim FN As String ' For File Name
FileLocation = "c:\a\*.xls"
FN = Dir(FileLocation)
Do Until Left(FN, 3) = "Don"

rename in here

FN = Dir
Loop
Application.ScreenUpdating = True
End Sub

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Hi-

I have a folder with 500 or so Excel files and they all start with a
specific date. For Example: 20070119_File1.xls

Does anyone have a macro that will loop through the folder and rename
just the date portion of the file? Example: I want to rename all of
the files that start with 20070119 to start with 20061231 but still
contain the rest of the filename.

Take:

20070119_File1.xls

and rename it:

20061231_File1.xls

Any help is appreciated!

Thanks,
Chris



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Macro to rename Excel files in a folder

Thanks Don. Appreciate the help.

Chris

Don Guillett wrote:
You could modify this to work within a DIR loop using mid oldname and mid
newname

Sub movefile()
OldName = "C:\oldfolderl\oldname.xls"
NewName = "C:\newfolder\newname.xls"
Name OldName As NewName
End Sub
Sub anotherfindfiles1() 'It does work.
Application.ScreenUpdating = False
Dim FN As String ' For File Name
FileLocation = "c:\a\*.xls"
FN = Dir(FileLocation)
Do Until Left(FN, 3) = "Don"

rename in here

FN = Dir
Loop
Application.ScreenUpdating = True
End Sub

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Hi-

I have a folder with 500 or so Excel files and they all start with a
specific date. For Example: 20070119_File1.xls

Does anyone have a macro that will loop through the folder and rename
just the date portion of the file? Example: I want to rename all of
the files that start with 20070119 to start with 20061231 but still
contain the rest of the filename.

Take:

20070119_File1.xls

and rename it:

20061231_File1.xls

Any help is appreciated!

Thanks,
Chris


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
How to create a copy of a folder having five files in it, & rename Matthews Excel Worksheet Functions 1 November 7th 06 03:42 PM
rename files in a folder Varun Nair Excel Programming 7 July 18th 06 01:18 PM
rename all files in a folder DIBS Excel Programming 3 January 5th 06 06:47 AM
Need Macro to rename excel files electrica7926 Excel Programming 12 February 17th 04 01:21 PM
rename folder o files with value from inside each wbk Max Bialystock Excel Programming 2 January 2nd 04 09:24 AM


All times are GMT +1. The time now is 06:04 PM.

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"