Renaming files in a directory

petko

Registered User.
Local time
Today, 23:04
Joined
Jun 9, 2007
Messages
89
Hi,

I have the following task: the code has to rename all available files according to a naming pattern in a given directory.
How could I approach this?

Appreciating any ideas

petkó
 
what is the naming pattern?
something like this:
Code:
const sFolder As String = "D:\data\"
const Pattern As String = "*.pdf"
Dim strFile As String
Dim i  As Integer
Dim coll As New Collection
strFile = Dir(sFolder & Pattern)
While strFile <> ""
    coll.Add strFile
    strFile = Dir()
Wend
For i = 1 To coll.Count
    Name sFolder & coll.Item(i) As sFolder & Format(Date(), "mmmyyyy") & "_" & Format(i, "000") & ".pdf
Next
 
Last edited:
Hi,

I have the following task: the code has to rename all available files according to a naming pattern in a given directory.
How could I approach this?

Appreciating any ideas

petkó

Maybe Allen Browne has the answer here: http://allenbrowne.com/func-02.html

If not what you want, browse his site, it's a wealth of information.
 

Users who are viewing this thread

Back
Top Bottom