Importing dynamically named files

ddikeht

Registered User.
Local time
Today, 02:16
Joined
Jun 9, 2005
Messages
22
Hunted around, but cannot seem to figure this out. What I am trying to do is take a dynamically named file and save it as a standard filename. for instance in a folder we have the following

C:\
elements_201106.txt
elements_201107.txt
elements_201108.txt

These correspond to monthly data dumps.

In access, I would love to have in my code an ability to read the prior months file (so in August 2011 I would grab elements_201107.txt) and rename it to just elements.txt

It should always look to the prior month, so in august, I would be looking at Julys file. I have played with the DoCmd.TransferText but not sure if that is right. Can anyone give me a snippet to play with?
 
Would this work for you?

Code:
stOldName = "c:\elements_2011" &format(month(now())-1,"00") & ".txt"
FileCopy stOldName, "c:\elements.txt"
 
you can rename a file with the NAME command.
 

Users who are viewing this thread

Back
Top Bottom