[AccessD] A2003:Rename Files in a folder

John Skolits askolits at ot.com
Mon Aug 7 10:13:00 CDT 2006


Here ya' go:


Function RenameFiles()

Dim strFileName As String
Dim strPath As String
'Set Your Path
'***Important, Make sure you include the last backslash
strPath = "C:\Temp\"

'Return the 'first' filename in the folder
strFileName = Dir(strPath)

Do Until strFileName = ""
    'rename it
    Name strPath & strFileName As strPath & "INV" & strFileName
    'If you just execute the DIR() function, it returns the next file in the
folder.
    strFileName = Dir
Loop

End Function


John Skolits

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Darren DICK
Sent: Monday, August 07, 2006 9:15 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] A2003:Rename Files in a folder

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





More information about the AccessD mailing list