Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: zip unzip zipping folder directory file Progress status bar
#DefineFunction UnZip(ZipFile,TargetDir) oShell = ObjectCreate("Shell.Application") oSource = oShell.NameSpace(ZipFile).Items() oTarget = oShell.NameSpace(TargetDir) oTarget.CopyHere(oSource,0) #EndFunction ; Test ZipFile = "C:\Test.zip" TargetDir = "C:\Test" DirMake(TargetDir) UnZip(ZipFile,TargetDir)
Zip via the Explorer shell and provide a progress bar.
; Note: that a progress bar only shows up if the zip process is taking a long time. #DefineFunction ZipFolder(Folder,ZipFile) Skipped = 0 If StrSub(Folder,StrCharCount(Folder),1)!="\" Then Folder = Folder:"\" ; Create an empty ZIP file Buffer = BinaryAlloc(22) BinaryPokeHex(Buffer,0,"50 4B 05 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00") BinaryWrite(Buffer,ZipFile) Buffer = BinaryFree(Buffer) ; Copy the files to the compressed folder oApp = ObjectCreate("Shell.Application") ForEach oItem In oApp.NameSpace(Folder).Items If oItem.IsFolder Then oFSO = ObjectCreate("Scripting.FileSystemObject") oFolder = oFSO.GetFolder(oItem.Path) If oFolder.Files.Count + oFolder.SubFolders.Count==0 Then Skipped = Skipped + 1 Else oApp.NameSpace(ZipFile).CopyHere(oItem) Else oApp.NameSpace(ZipFile).CopyHere(oItem) End If Next ; Keep script waiting until compression is done SrcItems = oApp.NameSpace(Folder).Items.Count While @TRUE If oApp.NameSpace(ZipFile).Items.Count + Skipped==SrcItems Then Break TimeDelay(0.5) EndWhile oFolder = 0 oFSO = 0 oApp = 0 #EndFunction ; Test ZipFolder("C:\Documents and Settings\Administrator","C:\Test.zip")
Article ID: W18191
Filename: Zip Folder with Progress Bar.txt
File Created: 2009:09:11:10:39:00
Last Updated: 2009:09:11:10:39:00