Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Change names of Files in a folder

I copy all these files into a new folder
File names are of standard = "XXXX MmmYy"
Thus I need to change their names to ""XXXX Mmm-1Yy"
So the code that I have is
Const Dest = "C:\Mis documentos\12 December 2005"
Dim FSO As Object
Dim f, f1, fc
Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.GetFolder(Dest)
Set fc = f.Files
For Each f1 In fc
f1.Name = Mid(f1.Name, 1, (Len(f1.Name) - 9)) &
Dateserial(year,month-1)
Next
It stops in the For next loop
Can someone help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Change names of Files in a folder

Not sure what names you are trying to give, but try this

Const Dest = "C:\Mis documentos\12 December 2005"
Dim FSO As Object
Dim f, f1, fc
Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.GetFolder(Dest)
For Each f1 In f.Files
Name f1.Path As Mid(f1.Name, 1, (Len(f1.Name) - 9)) & _
Format(DateSerial(Year(Date), Month(Date) - 1, 1), "yyyy-mm")
Next f1

Take backups first!

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"TISR" wrote in message
...
I copy all these files into a new folder
File names are of standard = "XXXX MmmYy"
Thus I need to change their names to ""XXXX Mmm-1Yy"
So the code that I have is
Const Dest = "C:\Mis documentos\12 December 2005"
Dim FSO As Object
Dim f, f1, fc
Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.GetFolder(Dest)
Set fc = f.Files
For Each f1 In fc
f1.Name = Mid(f1.Name, 1, (Len(f1.Name) - 9)) &
Dateserial(year,month-1)
Next
It stops in the For next loop
Can someone help?



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
Pulling pdf files from general folder to specific folder [email protected] Excel Discussion (Misc queries) 2 September 8th 09 09:41 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven[_2_] Excel Programming 1 January 24th 06 04:23 AM
create a list of worksheet names (from a single folder, or open files) Drew Excel Discussion (Misc queries) 2 April 15th 05 04:58 PM
Change names of files in a folder to match names in Excel Column saybut Excel Programming 4 February 9th 04 06:26 PM


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