goldenix Posted July 26, 2008 Share Posted July 26, 2008 (edited) In case some people do not know this, then there is 1 other way to compress files, for example, this code will compress all avi files in your scriptdir with max compression( myfile.avi - > myfile.rar )more info to customize your code: http://xona.com/2006/07/05g.htmlthis is what im using atm :Run this from a folder that has some avi files in it.You must have Winrar installed in C:\Program Files\WinRAR\WinRAR.exe to use this.$search = FileFindFirstFile("*.*") while 1 $file = FileFindNextFile($search) ; get filename to compress If @error Then ExitLoop ;===================================================== If StringInStr($file,'.avi') Then ; Rar only Avi Files $Rar_file = StringTrimRight($file,3) & '.rar' ;get filename, & replace its Extension with .rar _file_to_include($file) ; write File to compress into txt file Run('"C:\Program Files\WinRAR\WinRAR.exe" a -esh -m5 -mt0 -r -t "' & $Rar_file & ' " @"files_to_include.txt" ') ProcessWaitClose('WinRAR.exe') Sleep(2000) EndIf ;===================================================== WEnd FileClose($search) Func _file_to_include($_FILE) $file = FileOpen("files_to_include.txt", 2) ; Overwrite all text in file FileWriteLine($file, $_FILE & @CRLF) FileClose($file) EndFunc Edited July 26, 2008 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
TheSaint Posted July 27, 2008 Share Posted July 27, 2008 @goldenix What the hell are you talkin bout, there are many programs (exe, dll) out there for doin compression ... but you miss the point, this is not about using third party programs, it's about using a Windows feature to zip and unzip files and folders - so you need nothing more than AutoIt and Windows. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
torels Posted July 27, 2008 Author Share Posted July 27, 2008 @goldenixWhat the hell are you talkin bout, there are many programs (exe, dll) out there for doin compression ... but you miss the point, this is not about using third party programs, it's about using a Windows feature to zip and unzip files and folders - so you need nothing more than AutoIt and Windows. Exactly! Anyway I think there will be no compression level function Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
goldenix Posted July 28, 2008 Share Posted July 28, 2008 there are many programs (exe, dll) out there for doin compressionReally ? Havent seen a single one yet.Ether way the reason i posted this was, because the idea is very good, unfortunately last time i tested those UDFs they were all broken(didnt work perfectly) Do they Work now? CTRL+f & search for my user name on the first page. Well this winrar feature works flawlessly & has better compression, so i posted this for those who might need a flawless & working solution that you can use within autoit. My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
TalivanIBM Posted July 28, 2008 Share Posted July 28, 2008 _Zip_UnzipAll takes me always error 1 and decompress correctly Global $dirzip = "C:\Temp\eMule" DirCreate($dirzip) FileInstall("eMule.zip", $dirzip & "\eMule.zip", 1) $zip = _Zip_UnzipAll($dirzip & "\eMule.zip", @ProgramFilesDir & "\eMule", 16) and in _Zip_SearchInFile you use _zip_unzip but call with only 2 arguments, and takes error because need 3, i supose you would use _zip_unzipall of only 2 args. Link to comment Share on other sites More sharing options...
TalivanIBM Posted July 28, 2008 Share Posted July 28, 2008 Escuse i find my error in my script, i was taking the return value not the error value in UnzipAll..... Link to comment Share on other sites More sharing options...
cyanidemonkey Posted September 16, 2008 Share Posted September 16, 2008 (edited) is there a way to test if compression is taking place? is there a process name i could check is running or something while compressing?it seems if i call _Zip_AddFolder it runs the function, sets up the zipping and returns to the main script. i see my main script moves on while the compressions is taking place, which is all good, except in my case, i have added the files to a temp folder as part of a filtering process first, then run the _Zip_AddFolder i then use DirRemove to remove my temp folder (which brings up an error saying it can't zip a file because it don't exsist).psudo example$zippy = _Zip_Create(GUICtrlRead($expDestDir)) _Zip_AddFolder($zippy, $zipsource & "\",16) <<<something in here to check if zipping is still in process before moving to next line? DirRemove($zipsource & "\", 1) Edited September 16, 2008 by cyanidemonkey My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator Link to comment Share on other sites More sharing options...
cyanidemonkey Posted September 17, 2008 Share Posted September 17, 2008 found a way around my issue in above post, thought I'd share. it's a bit hoarish, and will only work if the compressing dialog box is set to appear (flag can not be set to 4) but it'll do for now. ProgressSet(95 , "Zipping Exported Files/Folders. Please Wait...", " Compressing...") _Zip_AddFolder($zippy, $zipsource & "\",16) WinWait("Compressing...", "", 3) ;<-- wait a bit first, small # of files/folders won't bring up progress box If WinExists("Compressing...") Then WinWaitClose("Compressing...") EndIf ProgressSet(98 ,"Removing tempoary files...", " Cleaning up...") DirRemove($zipsource & "\", 1) My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator Link to comment Share on other sites More sharing options...
torels Posted September 18, 2008 Author Share Posted September 18, 2008 use _Zip_Count() to count the files in the zip file and then move on cheers Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
AskThatDude Posted September 18, 2008 Share Posted September 18, 2008 (edited) use _Zip_Count()to count the files in the zip fileand then move on cheersHey Torels,I'm not sure what I am doing to generate this error but I cannot seem to add files to zip files I have already created. I keep receiving an error message making reference to $on = $oApp.NameSpace($hZipFile).Items.CountI have read through this topic but still cannot find the solution. All paths are valid and the txt file does exist. Here is the code I'm using.CODE#include <Zip.au3>$ZipFile = "D:\Home\Test.zip"$ZipFile = _Zip_Create($ZipFile)_Zip_AddFile($ZipFile, "D:\Home\Test.txt")_Zip_Count($ZipFile) Edited September 18, 2008 by AskThatDude Link to comment Share on other sites More sharing options...
cyanidemonkey Posted September 18, 2008 Share Posted September 18, 2008 @ torelsuse _Zip_Count()to count the files in the zip fileand then move on cheersyeah, tried that, it gave me the number of files/folder in the root of the zip, didn't count the sub files/folders. and in my case i need to count only files, not folders.also tried smashlies _Zip_TotalCount() but it returned a string of words, may be due to OS? i'm using XP, when i checked the full string returned by $oDir.GetDetailsOf it had no file or folder count in it, only file size etc (returns file/folder count on folders, but not .zips).oh, cheers for sharing the code, it has come in very handy.@ AskThatDudei had a simular issue also, it proberly not the _Zip_Count() causing it, but perhaps when you call _Zip_AddFile().i am using an older version of AutoIt (3.2.4.7) which i think is what caused it. the error i got was regarding a With loop.when i looked in zip.au3 I found there was the With loop commented out in the _Zip_AddFile() function, so i uncommented the With loop and commented out the Do loop and it worked on my system. also i changed$nn = $oApp.Namespace($hZipFile).Items.Count to$nn = .Items.Countnot sure if this is a good thing to do as a work around. My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator Link to comment Share on other sites More sharing options...
trancexx Posted September 19, 2008 Share Posted September 19, 2008 If I may suggest a little change in _Zip_Create() function to avoid possible problems and to optimize it. Maybe should look like this: Func _Zip_Create($hFilename, $overwrite = 0) If FileExists($hFilename) And $overwrite = 0 Then Return SetError(1, 0, 0); file already exists Local $hFp = FileOpen($hFilename, 26) ; 2+8+16 FileWrite($hFp, '0x504B0506000000000000000000000000000000000000') FileClose($hFp) If Not FileExists($hFilename) Then Return SetError(2, 0, 0); zip file not created Return 1 ; zip file created successfully EndFunc btw, there is problem inside _Zip_SearchInFile() ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
furrycow Posted September 20, 2008 Share Posted September 20, 2008 No matter what i write when using _Zip_UnzipAll, i always get the error...C:\Program Files\AutoIt3\Include\Zip.au3(339,51) : ERROR: _Zip_Unzip() called with wrong number of args. _Zip_Unzip($hZipFile, @TempDir & "\tmp_zip.file") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Program Files\AutoIt3\Include\Zip.au3(216,62) : REF: definition of _Zip_Unzip().Func _Zip_Unzip($hZipFile, $hFilename, $hDestPath, $flag = 4)Would it be something i have written? Instant Lockerz Invite - www.instantlockerzinvite.co.uk Link to comment Share on other sites More sharing options...
trancexx Posted September 21, 2008 Share Posted September 21, 2008 (edited) No matter what i write when using _Zip_UnzipAll, i always get the error...C:\Program Files\AutoIt3\Include\Zip.au3(339,51) : ERROR: _Zip_Unzip() called with wrong number of args. _Zip_Unzip($hZipFile, @TempDir & "\tmp_zip.file") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:\Program Files\AutoIt3\Include\Zip.au3(216,62) : REF: definition of _Zip_Unzip().Func _Zip_Unzip($hZipFile, $hFilename, $hDestPath, $flag = 4)Would it be something i have written?No, it's not you. You need to edit that line inside Zip.au3 (comment it off for now if you don't know how or till torels show you how to do it) Edited September 21, 2008 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
torels Posted September 21, 2008 Author Share Posted September 21, 2008 (edited) Try this $somefile = "myfile.txt" ;example file (the file name in the zip archieve) $Dest = "C:\mynewfile.txt" ;the file once extracted _Zip_Unzip($hZipFile, $somefile, $Dest) ;there you go! Edited September 21, 2008 by torels Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
torels Posted September 21, 2008 Author Share Posted September 21, 2008 If I may suggest a little change in _Zip_Create() function to avoid possible problems and to optimize it. Maybe should look like this: Func _Zip_Create($hFilename, $overwrite = 0) If FileExists($hFilename) And $overwrite = 0 Then Return SetError(1, 0, 0); file already exists Local $hFp = FileOpen($hFilename, 26) ; 2+8+16 FileWrite($hFp, '0x504B0506000000000000000000000000000000000000') FileClose($hFp) If Not FileExists($hFilename) Then Return SetError(2, 0, 0); zip file not created Return 1 ; zip file created successfully EndFunc btw, there is problem inside _Zip_SearchInFile() Don't like the Return 1 Returning the filename just makes life simpler so you get _ZipAddFile($zipfile,"File1.txt") insead of _ZipAddFile("C:\mypath\myzipfile.zip","File1.txt") the fileopen 26 is neat >_< @cyanidemonkey: you don't need the number of files/subfolders in the zip... Onche the number of elements in the .zip file are the same as the Directories/files (not counting subfolders obviously) you know that the files have finished copying in the zip Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
rjf7r Posted September 22, 2008 Share Posted September 22, 2008 I just started using zip.au3, and I'm using _Zip_UnzipAll to unzip a compressed folder with one file in it into an existing folder. The folder usually has an older version of the extracted file, which I want replaced. _Zip_UnzipAll always puts up the "do you want to replace" dialog box, even if I use a flag value of "16" for "yes to all". I still have to click on "yes to all" or "yes". Why? Link to comment Share on other sites More sharing options...
trancexx Posted September 22, 2008 Share Posted September 22, 2008 I just started using zip.au3, and I'm using _Zip_UnzipAll to unzip a compressed folder with one file in it into an existing folder. The folder usually has an older version of the extracted file, which I want replaced. _Zip_UnzipAll always puts up the "do you want to replace" dialog box, even if I use a flag value of "16" for "yes to all". I still have to click on "yes to all" or "yes". Why?You need to check if file exists before calling _Zip_UnzipAll() and delete it using FileDelete() or whatever to avoid that behavior.That flags are not working for autoit. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
torels Posted September 23, 2008 Author Share Posted September 23, 2008 Hi there, New Zip UDF Coming Soon... Added _Zip_IsCompressed() which pauses the script until the file is fully compressed Fixed Various Bugs and Changed Some Functions Fixed: _Zip_SearchInFile Fixed: _Zip_Count New post tomorrow including all new features and updates >_< stay tuned... Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
torels Posted September 24, 2008 Author Share Posted September 24, 2008 Hi there, I Just posted the New Zip file with the new functions I removed _Zip_IsCompressed()(see previous post) and integrated it in _Zip_AddFile & _Zip_AddFolder Hope you like the new version Change Log is in the first Post Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
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