Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change File Extension Of All Files In A Folder 1

Status
Not open for further replies.

dominicdunmow

Technical User
Jul 28, 2004
125
CA
Hi there,

I have reports that are to delivered to a specifie folder. They appear with no file extension, so I have to add ".txt" to each one. Every month the filenames are differnt.

I'm trying to come up with a way of adding txt to the end of every file in the folder so I can import them. I ahve the importing covered hit' just the renaming.

Can anyon help please?

Thanks
 
use shell commands...

I think you can pass those directly to the system...

ren * *.txt

--------------------
Procrastinate Now!
 
Hello dominicdunmow!

Try something along these lines:
Code:
Dim objFileSys as Object
Dim objFile as Object
Set objFileSys = CreateObject("Scripting.FileSystemObject")

For Each objFile In objFileSys.GetFolder("path").Files
    objFile.Name = objFile.Name & ".txt"
Next

Set objFileSys = Nothing

Depending on your needs, you may consider putting in a check to make sure you don't end up with a file such as "C:\file.txt.txt".

Good luck!

He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top