Need help on zipping files deleting the same

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
Posts: 14
Joined: Tue May 15, 2007 4:13 pm

Need help on zipping files deleting the same

Post by praseetha »


I have a script that zips all teh files in the source folder & then waits for some time & then deletes all the files that are already zipped. Is there an inbulit function to check if the zipping process is complete or not before it starts delete. In the script, i have given a wait time of 10 mins before delete starts.

I could not attach the script due to some err: so copying the same as below:

NOTE: There are some thousands of files that needs to be zipped at a time & it takes more time to complete the same.

Set WshShell = WScript.CreateObject("WScript.Shell")Set oShell = CreateObject("WScript.Shell")Set oFileSys1 = CreateObject("Scripting.FileSystemObject")MySource1 = "d:ImportedSuccessfully"
Date1= day(Date())Date2=Month(Date())Date3=Year(Date())Date4=Hour(Now())Date5=Minute(Now())
MyTarget1 = "d:ImportedSuccessfully" & " " & Date3 & Date2 & Date1 & "_" & Date4 & Date5 & ".zip"
Set src1=oFileSys1.getfolder(MySource1)Set files1=src1.files
MyHex = Array(80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0)For i = 0 To UBound(MyHex)
MyBinary = MyBinary & Chr(MyHex(i))
If oFileSys1.fileExists(MyTarget1) Then 'Checks If the zip folder already exists or not
'msgbox MyTarget1 & "-Zipfolder already exists"
Set oCTF = oFileSys1.CreateTextFile(MyTarget1, True) 'Creates the zip folder with the current date oCTF.Write MyBinary oCTF.Close
Set oCTF = Nothing Set objShell = CreateObject("Shell.Application") Set DestFldr1=objShell.NameSpace(MyTarget1) Set SrcFldr1=objShell.NameSpace(MySource1) Set FldrItems1=SrcFldr1.Items
For Each objitem In FldrItems1 If instr(1,nm,".",0) Then wscript.sleep 100 DestFldr1.CopyHere objitem 'Copies the contents to zip folderEnd If
wscript.sleep 100 Next
End If wscript.sleep 60000 Set oFileSys1 = Nothing
Set oFileSys_1 = CreateObject("Scripting.FileSystemObject")If oFileSys_1.fileExists(MyTarget1) Then
Set dest_Folder1=objShell.NameSpace(MyTarget1) Set dest_Items1=dest_Folder1.items For Each objitem In dest_Items1 'Checks the files in zipped folder with the destination folder For Each file In files1
If o_nm = nm Then 'checks the files already zipped and deletes them file.delete Else
End If Next Next WScript.Sleep 60000
End If
Set oFileSys_1 = Nothing

Can someone help me sort out this prob: