[AccessD] A2003:Rename Files in a folder

Andy Lacey andy at minstersystems.co.uk
Mon Aug 7 10:47:21 CDT 2006


Hiya matey. This might help.

Function RenameFilesInFolder(strFolder As String)
Dim strFullFolder As String
Dim strFilename As String
Dim strFullFileName As String
Dim strNewFullFilename As String

strFullFolder = strFolder & IIf(Right(strFolder, 1) <> "\", "\", "")
strFilename = Dir(strFullFolder & "*.*", vbNormal)
Do While strFilename <> ""
strFullFileName = strFullFolder & strFilename
strNewFullFilename = strFullFolder & "inv" & strFilename
Name strFullFileName As strNewFullFilename
strFilename = Dir
Loop


End Function

See ya.

--
Andy Lacey
http://www.minstersystems.co.uk




--------- Original Message --------
From: "Access Developers discussion and problem solving"
<accessd at databaseadvisors.com>
To: "'Access Developers discussion and problem solving'"
<accessd at databaseadvisors.com>
Subject: [AccessD] A2003:Rename Files in a folder
Date: 07/08/06 13:19


Hi all

I have to loop through a folder and rename all the files in it to have some
text
as a prefix

For EG there may be a folder C:CoolFolder
In it may be 5 files or 5000 files that are all sequentially numbered and
named
like...
1012.pdf, 1013.pdf, 1014.pdf etc etc

What I need to do is loop all the files and add a prefix such as "inv" so
the
file names become
inv1012.pdf, inv1013.pdf, inv1014.pdf etc etc

Any pointers - anyone got any file renaming snippets they'd care to share?

many thanks in advance

Darren


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

________________________________________________
Message sent using UebiMiau 2.7.2




More information about the AccessD mailing list