Renaming files in a directory (1 Viewer)

petko

Registered User.
Local time
Today, 13:34
Joined
Jun 9, 2007
Messages
85
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ó
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:34
Joined
May 7, 2009
Messages
19,242
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:

adrianscotter

Registered old fart!
Local time
Today, 12:34
Joined
Jul 7, 2014
Messages
124
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

Top Bottom