Jump to content

Unzip your files without progress bar

Recommended Posts

Very simple: I had seen many examples of unzipping files (Zip) archive, but most of those example where using either some external .dll or are performing the job with the progress bar. Here is a small example how you can unzip your files without any external libraries and without any progress bar


$objShell5 = ObjCreate ("Shell.Application")

Enjoy :)

Link to post
Share on other sites

By "progress bar" I mean - the windows progress bar which is showing- that your files are moving from one directory to another. And if you have say 10000 files in zip file? So if you don't like that win progress bar- this example is right for you :)

Ah, btw- if you do want the progress bar, then just remove this part from the code

Edited by topten
Link to post
Share on other sites

Nice, what limitation of OS does this have being object based (XP, 7, Vista, 8, 10)

I wrote a program to update maps for a 911 system and hated how the transfer dialog came up when the file was done downloading.

Edit: Here we go a copy of my code updated with this method.
I commented out the 2 lines that were doing the unzipping before, and I can remove the Include for Zip.au3

I noticed that you must have the directory already or this will not work so I added in the DirCreate()

My question here is how I was checking the return of the _Zip_UnzipAll() for log file usage.  How can I check the return of this unzip method so I can log the results accurately?

#Include <Array.au3>
#Include <File.au3>
#Include <Zip.au3>

$sMaps = "C:\Tiburon\"  ;Where To Save Maps

$aZip = _FileListToArray("C:\Tiburon", "*.zip", $FLTA_FILES, True) ;Get A List of All .Zip Files
If @Error Then ;If No Downloads Exit
    ;MsgBox(0, "", @Error)
Else ;Else Get The Highest Version Map .Zip Package and Save to $sZip and get Name and save in $sMap2
    $sZip = $aZip[$aZip[0]]
    $aMap = StringSplit($sZip, "\")
    $sMap2 = StringTrimRight($aMap[$aMap[0]], 4)
    $sMaps &= $sMap2

$sLogPath = "C:\Tiburon\" & $sMap2 & ".log" ;Create Our Log File Path with $sMap2 as the Name
_FileWriteLog($sLogPath, "New Map Package " & $sMap2 & " was downloaded") ;Write To Log that The .Zip was downloaded
$vStep1 = DirRemove($sMaps, 1) ;If Zip was Already Extracted Delete As To Extract New (Prevent Corrupted Downloads)
If $vStep1 = 1 Then _FileWriteLog($sLogPath, "Deleted old " & $sMap2 & " folder") ;Write To Log That Old Folder Was Found and Deleted
$objShell5 = ObjCreate("Shell.Application")
$FilesInZip5 = $objShell5.NameSpace($sZip).items
;$vStep2 = _Zip_UnzipAll($sZip, $sMaps, 1) ;Unzip Our File
;If $vStep2 = 0 Then _FileWriteLog($sLogPath, "Successfully Unziped Package for " & $sMap2) ;Log That We Unzipped Our File
$vStep3 = FileDelete($sZip) ;Delete Zip Package When Finished
If $vStep3 = 1 Then _FileWriteLog($sLogPath, "Successfully Deleted " & $sMap2 & " .Zip Package") ;Log That We Deleted Our Zip File Successfully


Edited by ViciousXUSMC
Link to post
Share on other sites
  • 1 year later...

   $objShell5 = ObjCreate ("Shell.Application")


I used this code for extracting my homework but I got this error instead:-

$FilesInZip5=$objShell5.NameSpace($ZipFile5)^ ERROR

What Could be the possible reason.
I am using this inside a function


Link to post
Share on other sites
  • Moderators

You need to add some error checking to your script. Look at IsObj in the help file, and look at placing it there after your ObjCreate statement. You can also try running the script with #RequireAdmin at the top.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites
  • Moderators

Did you try with #RequireAdmin? You need to error check the rest of the script:

  • Confirm the zip file exists in the directory you reference in line 1
  • Confirm the directory you reference in line 2 is accessible, and you have rights to it
  • Confirm you can create the Shell.Application in line 3
  • etc. etc. etc.

Look at @error and FileExists in the help file.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By obiwanceleri
      Good evening! 
      I know this has been done to death in many programming languages and probably even in AutoIt. 
      But couldn't help myself and as a learning challenge I wrote "yet another converter" LOL
      I need your help to test it and show me "the error of my ways" but in a nutshell here's what it can do already (taken from my source file) :
      Converts all zip files recursively into a 7Zip file, with max compression REQUIRES AUTOIT Version + Exact copy with attributes and folder structure + Extensive error checking, including files blocked by anti-virus (by file count) + Can stop process and restart later with the use of a log file + Can pause process (but in between compressing / extracting files) + Creates a .CSV file that can be used to check on compression ratios + Dynamic GUI that enables user to see console while 7zip is working + Gui can be stretched horizontally for long filenames + Up to 5 retries while transfering compressed files + Checks free space (at startup) to make sure you don't kill your OS LOL + Have converted 10,000+ files with no issues in file integrity. + Open to suggestions and program free to modify to your liking + Will eventually be fully modular and configurable (if there is interest for this) + Exit codes so you can have an idea where program went wrong (if it did) + Fully commented so users can tinker away. - Cannot save archive comments. - Not FULLY tested yet, do not use on .zip files that have no backups The program also has a very minimal GUI that can be stretched. Not a huge fan of million-button interfaces.
      I also assume some people running this program will have a 1024x768 monitor so the GUI is made accordingly.
      There is no way I am keeping this script for myself. If this is useful to anybody, feel free to use it and modify it. All I ask is you credit me (as I will credit those who contribute).
      Now here's the issues that are left to fix. Any help is greatly appreciated and I will add your name in the credits if you so wish.
      - For some reason while compression is under way, all my current explorer windows flicker; notably the cut-and-paste part. I can't seem to narrow it down. 
      - Also context menu is closed in explorer every time program compresses / extracts a new file
      - I've added support for retries if, for some reason, AutoIt can't move the converted file. This happened once after 5000-6000 conversions. Now that I've programmed the retries, the process is somewhat slower. It shouldn't affect speed though.  
      - After compressing 10,000+ files (Yes I have that many zip files! Think Mame) I've had a system meltdown. There's a leak somewhere. Am I supposed to close something and I'm not? I've added _IsPressed() lately so closing that .DLL is not the cause of this leak. 
      - Subtracting one array from another was a tricky thing to program (happens when user stops and restarts process), if you can think of a faster way I'm all in.
      Obviously if you find bugs or have suggestions, I'm all ears. 
      Changelog is included in the source file, including credits.
      PLEASE DON'T CONVERT ALL YOUR FILES YET. It's not fully tested (well I tested it but I need others to test too).
    • By Exit
      For my next project I would like to send files with "alternate data streams" by email in ZIP format.
      I can not use any external program like 7-Zip or WinRAR. (They would fit😥)
      Who knows how to create a ZIP file with "alternate data streams" included with the Powershell command "Compress-Archive"? 
      Here a test script:  (save as "ADSTester.cmd")
      @rem Try to create a zip file with alternate data streams (ADS) included @rem Housekeeping @cls @del ADSTester.zip >nul: @RD /S /Q Extracted >nul: @del ADSTester.txt >nul: @rem End of Housekeeping echo This is the ADSTester.txt file >ADSTester.txt echo This is the ADSTester.txt:Part1 file >ADSTester.txt:Part1 echo This is the ADSTester.txt:Part2 file >ADSTester.txt:Part2 dir /r ADSTester.txt @rem See the 3 files @rem **************************************************************** @rem **************************************************************** @rem Please alter the next lines to include the alternate data streams. powershell Compress-Archive -Path .\ADSTester.txt -Update -DestinationPath ADSTester.zip powershell Expand-Archive -Path ADSTester.zip -DestinationPath .\Extracted\ dir /r Extracted\ADSTester.txt @rem Only one file left :-( pause  
    • Guest
      By Guest
      Is it possible to unzip a zip file in Autoit without using a dll!
      My script downloads a zip file to a temporary directory (successfully) and it must be unzipped to (Or moved to after unzip) another a folder which just happens to be
      @scriptdir & "file.exe" Thanks in advance
    • By Tersion
      Here the this wiki page with list of available UDFs for data compression. For my tasks I only need ZIP support, so I started looking at pure AutoIt UDFs without any 3rd party dlls. And found out that most of available realizations uses standard ("native method") Windows dll - "zipfldr.dll". So for now I chose ZIP UDF by wraithdu. I've tested it on Windows 7 (x64) and it seem works fine. But here the comment from another topic where user says that Windows 10 discontinued support of "zipfldr.dll". Now I confused. I don't have around any Windows 10 machine to tested it. So maybe someone could confirm or deny that? Or maybe would better to switch to UDF with 7zip dll?
      I need an advice...
    • By tintin92

      How can I automatically download a list of zip files, like the ones in the quote, using a AutoIt script?
      Is it possible with AutoIt script?
  • Create New...