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

How to rename a file with increments 1

Status
Not open for further replies.
Mar 12, 2003
678
US
How do I use the current date and time in the renaming process within this code. Right now I am just using the date. I want to add time also.

Function Main()
Dim FSO, sFileName

Set fso = CreateObject("Scripting.FileSystemObject")
sfilename=("\\mbhqrdp01\Exports\GDMManual\gpexport.txt")



' Check for file and return appropriate result
If FSO.FileExists(sFilename) Then
Main = DTSStepScriptResult_ExecuteTask
Set bFile = fso.GetFile("\\mbhqrdp01\Exports\GDMManual\gpexport.txt")
aYear = year(now)
aMonth = month(now)
aDay = day(now)-1
filename = "gdm" &aMonth &aDay&aYear&".txt"
bFile.move ("\\mbhqrdp01\Exports\gdm\"&filename)
Else
Main = DTSStepScriptResult_ExecuteTask
End If

Set FSO = Nothing
End Function
 
I think you only need to add hour(now), minute(now), or something along those lines.

Hope this helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top