topten Posted October 19, 2015 Posted October 19, 2015 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$ZipFile5="C:\file.zip" $ExtractTo5="C:\folder" $objShell5 = ObjCreate ("Shell.Application") $FilesInZip5=$objShell5.NameSpace($ZipFile5).items $objShell5.NameSpace($ExtractTo5).CopyHere($FilesInZip5,0x4)Enjoy ViciousXUSMC 1
TheDcoder Posted October 20, 2015 Posted October 20, 2015 performing the job with the progress bar??? Progress bar? You can extract zip files using a progress control!? EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
topten Posted October 20, 2015 Author Posted October 20, 2015 (edited) 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,0x4 Edited October 20, 2015 by topten
TheDcoder Posted October 20, 2015 Posted October 20, 2015 Oh ... EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
ViciousXUSMC Posted October 21, 2015 Posted October 21, 2015 (edited) 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.au3I 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) Exit Else ;Else Get The Highest Version Map .Zip Package and Save to $sZip and get Name and save in $sMap2 ;_ArrayDisplay($aZip) $sZip = $aZip[$aZip[0]] $aMap = StringSplit($sZip, "\") $sMap2 = StringTrimRight($aMap[$aMap[0]], 4) $sMaps &= $sMap2 EndIf $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 DirCreate($sMaps) $objShell5 = ObjCreate("Shell.Application") $FilesInZip5 = $objShell5.NameSpace($sZip).items $objShell5.NameSpace($sMaps).CopyHere($FilesInZip5,0x4) ;$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 October 21, 2015 by ViciousXUSMC
topten Posted October 22, 2015 Author Posted October 22, 2015 ViciousXUSMC , "How can I check the return of this unzip method so I can log the results accurately?"I am not sure yet about how to check the return, I will try to research that question. In my case- the script was waiting untill the files are unzipped and then it went on further execution
ViciousXUSMC Posted October 22, 2015 Posted October 22, 2015 Yes it is waiting, and I was able to track down the page for the method..CopyHere does not have any return values, so guess I would need to find another way or just assume it works and log it after the extraction. https://msdn.microsoft.com/en-us/library/windows/desktop/bb787866(v=vs.85).aspx?f=255&MSPPError=-2147217396Â
topten Posted October 22, 2015 Author Posted October 22, 2015 ViciousXUSMC, But what actually are you trying to achieve by logging?
o_v_shake Posted November 28, 2016 Posted November 28, 2016 $ZipFile5="C:\Users\Abhishek\Downloads\BackPack_Resources\ComputerSystemsManagement_Lectures.zip"   $ExtractTo5="C:\Users\Abhishek\Downloads\BackPack_Resources\CSE131\Lectures"   $objShell5 = ObjCreate ("Shell.Application")   $FilesInZip5=$objShell5.NameSpace($ZipFile5).items   $objShell5.NameSpace($ExtractTo5).CopyHere($FilesInZip5,0x4)  I used this code for extracting my homework but I got this error instead:- $FilesInZip5=$objShell5.NameSpace($ZipFile5).items $FilesInZip5=$objShell5.NameSpace($ZipFile5)^ ERROR What Could be the possible reason. I am using this inside a function Â
Moderators JLogan3o13 Posted November 28, 2016 Moderators Posted November 28, 2016 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!
o_v_shake Posted November 28, 2016 Posted November 28, 2016 isObj is returning 0 for ($ZipFile5) this means it is not a object variable. where could I have gone wrong?
Moderators JLogan3o13 Posted November 28, 2016 Moderators Posted November 28, 2016 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!
o_v_shake Posted November 28, 2016 Posted November 28, 2016 Okay, Its working Now. I just copied the code outside the function i had defined But when I copied it back inside the function it stops working again Any Clue?
Moderators JLogan3o13 Posted November 28, 2016 Moderators Posted November 28, 2016 None, since you didn't post the code in its entirety... "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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now