Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Renaming Files

Anyone have a method for looping through a folder and renaming a file based on
a criteria.

I don't necessarily need the dir loop. But how do you rename something, much
less based on a criteria? Use a .filesearch object

For example, say I have things called October Report.doc, October Sales.xls.
October Song.mp3

I don't want to open them just rename the files from Oct to Nov Report.doc,
October Sales.xls, etc

I just want to replace part of the name based on a search criteria. Possible?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Renaming Files

loop through the dirrectory..

Dim FN as string, MyPath As String
MyPath = "C:\Temp\FolderX\"
FN = DIR(MyPath & "*.*")
DO UNTIL FN=""
If FN LIKE ("Nov*.*) Then
Rename MyPath & FN, MyPath & "Dec " & Mid(FN,4)
End If
FN = DIR
LOOP



Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
Anyone have a method for looping through a folder and

renaming a file based on
a criteria.

I don't necessarily need the dir loop. But how do you

rename something, much
less based on a criteria? Use a .filesearch object

For example, say I have things called October

Report.doc, October Sales.xls.
October Song.mp3

I don't want to open them just rename the files from Oct

to Nov Report.doc,
October Sales.xls, etc

I just want to replace part of the name based on a

search criteria. Possible?

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Renaming Files

Thanks. Sounds great.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Renaming Files

It didn't like

If FN LIKE ("Nov*.*) Then

Is the LIKE command valid?

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
Renaming excel files in a folder Rhett C[_2_] Excel Discussion (Misc queries) 1 January 29th 10 05:23 AM
Excel Renaming Files When Opening Using File Convertor William McCann Excel Discussion (Misc queries) 0 November 25th 09 03:41 PM
Renaming Files w/Excel Confused VB Person Excel Discussion (Misc queries) 4 March 21st 08 09:26 AM
Batch renaming of many worksheets in Excel files? Lumen S Excel Discussion (Misc queries) 2 August 17th 06 09:48 PM
Renaming Files Bear Excel Discussion (Misc queries) 2 December 5th 05 09:02 PM


All times are GMT +1. The time now is 09:39 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"