Path2Winrar = "c:\Program Files\WinRAR\WinRAR.exe" Path4Archives = "d:\dav\2\" BackupDepth = 4 Set WshShell = WScript.CreateObject("WScript.Shell") Set objNetwork = CreateObject("WScript.Network") Set FSO = CreateObject("Scripting.FileSystemObject") strMyDoc = WshShell.SpecialFolders("MyDocuments") arcPrefix=LCase(objNetwork.ComputerName & "_" & objNetwork.UserName) arcName = Path4Archives & arcPrefix & "_" & Replace(Replace(CStr(now),":","-")," ","_") & ".rar" cmd = """"& Path2Winrar & """ a -r -dh -INUL -x*.mp3 -x*.fcd -x*.avi -x*.exe -x*.jpg -x*.tif -pPASSWD """ & arcName & """ """ & strMyDoc & """" WshShell.Run cmd, 1 , True Set Files= FSO.GetFolder(Path4Archives).Files Dim Backups() q=0 For Each File In Files FileName=LCase(File.Name) If (InStr(FileName, arcPrefix)=1 ) Then q=q+1 End If Next ReDim Backups(q-1,1) q=-1 For Each File In Files FileName=LCase(File.Name) If (InStr(FileName, arcPrefix)=1 )Then q=q+1 Backups(q,0)=Path4Archives & File.Name Backups(q,1)=File.DateLastModified End If Next c = False Do Until c c=True For w=0 To q-1 If CDbl(Backups(w,1)) < CDbl(Backups(w+1,1)) Then c=False b0=Backups(w,0) b1=Backups(w,1) Backups(w,0)=Backups(w+1,0) Backups(w,1)=Backups(w+1,1) Backups(w+1,0)=b0 Backups(w+1,1)=b1 End If Next Loop For w=BackupDepth To q FSO.DeleteFile Backups(w,0),True Next |