Change File Extension before importing

J

John W

I've created a database that will take large quantities of delimited text
files and import them to Access. Everything is working fine but I'm
wondering if there's some code that would change the file extension before
importing? The files are all text but they come to us with a .dpr
extension. If it were just a few files it would be no problem to just
change them manually, but I'm dealing with hundreds of files per week. Is
this possible to do?

Thanks!
 
K

Klatuu

Assuming all the files are in the same folder, you can use a combination of
the Dir function and the Replace function to rename all the files that end
with .dpr.

Dim strOldName as String
Dim strNewName as String
Dirm strFullName As String
Const conPath as String = "C:\SomeFolder\"

strFileName = Dir(conPath & "\*.dpr")
Do Until Len(strFileName) = 0
strOldName = conPath & strFileName
strNewName = Replace(strOldName,".dpr", ".txt")
Name strOldName As strNewName
strFileName = Dir
Loop
 
J

John W

This worked perfectly....Thanks for the help!

Klatuu said:
Assuming all the files are in the same folder, you can use a combination
of
the Dir function and the Replace function to rename all the files that end
with .dpr.

Dim strOldName as String
Dim strNewName as String
Dirm strFullName As String
Const conPath as String = "C:\SomeFolder\"

strFileName = Dir(conPath & "\*.dpr")
Do Until Len(strFileName) = 0
strOldName = conPath & strFileName
strNewName = Replace(strOldName,".dpr", ".txt")
Name strOldName As strNewName
strFileName = Dir
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top