rename unknown named files

S

s_smith_iet

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???
 
T

Tom Ogilvy

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
 
S

s_smith_iet

Amazing!!!!!!!!!!!
Thank you sooooo very much
Now what would I need to change if I wanted to use the same thing to
20,30 or more files?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top