View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default rename unknown named files

Sub RenameFiles()
s1 = "C:\Documents and Settings\Owner\My Documents\Work\P123\dat\"
s2 = "C:\Documents and Settings\Owner\My Documents\Work\P123\txt\"
sName = dir(s1 & "*.*")
i = 0
do while sName < ""
i = i + 1
name s1 & sname as s1 & i & ".dat"
sName = dir()
Loop

sName = dir(s2 & "*.*")
i = 0
do while sName < ""
i = i + 1
name s2 & sname as s2 & i & ".txt"
sName = dir()
Loop

End Sub

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
I have a bunch of different macros that are working at the moment the
only problem is that they will only work for a certain named file.

what I think would be the easiest way to make this work is to rename
the files in the folders.
these are the two folders which have the files I need to rename
C:\Documents and Settings\Owner\My Documents\Work\P123\dat
C:\Documents and Settings\Owner\My Documents\Work\P123\txt

Each folder would have 10 files in them at a time.


I would like to name them 1-10 dat and 1-10 txt if possible.

Any ideas???