Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Archive Script Problems

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,24491
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Archive Script Problems
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 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
 
 
Post #: 1
 
 RE: Archive Script Problems - 8/5/2005 8:44:10 AM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
What error do you get? If the copy or the delete fails, then your counting (i) is wrong. If the zip fails

next
If 0 < i Then
   cmdline = ZiperFile & WorkDir &   DestFile &  " " &  WorkDir2
   retcode = Wshshell.Run(cmdline, 1, True)
   Return = fso.MoveFile(WorkDir & DestFile, RemoteWorkDir & RemoteDestFile)
End If

(not tested)

(in reply to Qnavry)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Archive Script Problems Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts