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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy file adding a date stamp 1

Status
Not open for further replies.

skeeter66

MIS
Dec 7, 2004
13
US
How do I copy a file from one directory to another and add a date stamp to the file name as the previous days file will exist in the new directory?
 
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
Set oldFile = FSO.GetFile("c:\temp\filea.txt")
strNewFileName = Left(oldFile.Name, Len(oldFile.Name) - 4) & Replace(Date(), "/", "") & Right(oldFile.Name, 4)
Msgbox strNewFileName
 
ok, i dont like the 4 either but i couldnt be arsed to do an InStr(aFile.Name, "."), you can add that if your files have mixed length of file type string
 
Hello mrmovie,

We can always use .getbasename() and .getextensionname() methods to isolate out the "base" and "extension" parts. Extension can be all kinds in other os as well as in dos/windows.

regards - tsuji
 
thanks tsuji, i didnt know about .getbasename and getextensionname properties
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top