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

Add date and time to script 1

Status
Not open for further replies.

barbola

Technical User
Feb 27, 2003
1,132
CA
I have this as part of my script:

Code:
[green]'Set the Path & Filename of the Source file and the Destination 'file. [/green]

sSourceFile = "C:\TestData\Voucher.csv"
sOldFile = "C:\TestData\A"

sDestinationFile = "C:\TestData\bak\Voucher" & _
Year(Date) & _
Right("0" & Month(Date), 2) & _
Right("0" & Day(Date), 2) & _
".txt"

[green]'Create a File System Object[/green]

Dim pFSO
Set pFSO = CreateObject("Scripting.FileSystemObject")

[green]'Copy and rename the file
'The "True" parameter indicates that if the file already exists in the destination, then it will be overwritten
[/green]

Call pFSO.CopyFile(sSourceFile, sDestinationFile, True)
Call pFSO.DeleteFile(sOldFile, True)

I either need the time added or something other than "True" because if there are two files on the same day, I don't WANT it overwritten but I copied this from the only example that was available and I don't know how to make it do what I need.

thanks
 
something like this ?
sDestinationFile = "C:\TestData\bak\Voucher" & _
Year(Date) & _
Right("0" & Month(Date), 2) & _
Right("0" & Day(Date), 2) & _
[!]Right("0" & Hour(Now), 2) & _
Right("0" & Minute(Now), 2) & _[/!]
".txt"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Perfect. I'll give it a try.

thanks
b.
 
You might also want to use MoveFile to do the rename, that way you don't need to do the delete.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
or Shell.Application and not move or delete.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
I don't know what shell.application means.

Adding the time works perfectly however.

One thing I want to do is not have it do the move (copy/delete) if the application doesn't work.

This is an integration program (for Great Plains, but I didn't get answers in that forum) and when there is something wrong with the file, and the integration fails, I want it to NOT delete the original file.

I haven't looked into it much, but this will be needed because we go live with this app on Monday aaack!

thanks,
Barb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top