Login | |
|
 |
Archive Script Problems - 8/5/2005 8:31:46 AM
|
|
 |
|
| |
Qnavry
Posts: 2
Score: 0
Joined: 8/5/2005
Status: offline
|
I have this script that runs every night. It zips files that are older that a certain date. The problem I am having is that if there are no files that are older that the date specified the the script gives an error. Could someone look at this and let me know what I could do to fix it? Thanks The Script first adds the files to a array, Copies them to a backup folder, zips them then moves the zip file and deletes the backup folder. //////////////////////////////////////////////////////////////////////////////////////////////////////////// Option Explicit dim fso,WshShell, file, daysBack,toDelete(100000), i, ii,ZiperFile,WorkDir,WorkDir2,DestFile daysBack = 2 Dim currentdate, Cmdline,retcode,RemoteDestFile,RemoteWorkDir,Return, currentdate = now Set fso = CreateObject("Scripting.FileSystemObject") Set WshShell = WScript.CreateObject("WScript.Shell") ZiperFile = "C:\Pacl\Pacomp.exe -a -r " WorkDir = "c:\Progra~1\Test\" WorkDir2="c:\Progra~1\Test\Backuplogs\" DestFile = "Logs" & "(" & Month(currentdate) & "." & Day(currentdate) & "." & Year(currentdate) & ")" & ".zip" RemoteWorkDir = "k:\Backup\" RemoteDestFile = DestFile Dim Ext For Each file In fso.GetFolder(WorkDir).files Ext = Right(file,3) If (DateValue(file.datelastModified) < DateValue(Now - daysBack)) and ext = "log" Then toDelete(i) = file.Path i = i + 1 End If Next Set f = fso.CreateFolder(WorkDir2) for ii = 0 to i-1 Return = fso.CopyFile(toDelete(ii), WorkDir2) fso.DeleteFile (toDelete(ii)) next cmdline = ZiperFile & WorkDir & DestFile & " " & WorkDir2 retcode = Wshshell.Run(cmdline, 1, True) Return = fso.MoveFile(WorkDir & DestFile, RemoteWorkDir & RemoteDestFile) fso.DeleteFolder("c:\Progra~1\Test\Backuplogs") Set fso = Nothing set WshShell = nothing
|
|
| |
|
|
|
|
|