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

Renaming file with today's date as part of the name

Status
Not open for further replies.

jcash35010

Programmer
Jul 22, 2003
21
0
0
US
Ok, I need to copy a file or rename the file with the date as part of the name. What command can i use within my script to do this?

Thanks!
 
I also need to do this, here is what I have so far, but this isn't working for me:

Dim d
d = Now()
FileSystemObject.CopyFile "c:\test\testfile.txt", "c:\test\testfile-%d%.txt"


Any suggestions?
 
Try something like this:
Code:
Dim d,fso
d = Now()
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile "c:\test\testfile.txt", "c:\test\testfile-"&d&".txt"

Hope This Help
PH.
 
PHV, that didn't run, syntax error. Ralphtrent in another post came up with this:

t = DatePart("h", time) & DatePart("n", time) & DatePart("s", time)
d = DatePart("m", date) & DatePart("d", date) & DatePart("yyyy", date)

srcFile = "vpnPO.txt"
desFile = "vpnPO_"&t&"_"&d&".txt"
Dim oFSO, getFile
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.CopyFile "c:\temp\"&srcFile,"c:\temp\"&desFile, True
Set oFSO = Nothing

That one did it for me...
 
TRY THIS

Dim d,fso
d = REPLACE(NOW,":","")
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile "c:\V7\testfile.txt", "c:\V7\testfile" & REPLACE(D,"/","") & ".TXT"

It didn't like the : and / in the date and time. The replace will take them out.

ddw
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top