Wednesday, April 12, 2006

DTS: ActiveX rename File with Time and Date and Move

'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************

' Copy File
' Option Explicit

Function Main()

Dim oFSO
Dim sSourceFile
Dim sDestinationFile
Dim sdate
sdate = CStr(Year(Date)) & CStr(Month(Date)) & CStr(Day(Date) & CStr(Hour(Time)) & CStr(Minute(Time))& CStr(Second(Time)))
Set oFSO = CreateObject("Scripting.FileSystemObject")

sSourceFile = "\\svrdev\D$\MSSQL\Log_Ship_Test\VSTLog.trn"
sDestinationFile = "\\svrTest\D$\DBA\LogShipping_Test\VSTLog" & sdate &".trn"
'MsgBox( sdate)


oFSO.CopyFile sSourceFile, sDestinationFile

' Clean Up
Set oFSO = Nothing

Main = DTSTaskExecResult_Success
End Function