Jump to content
obiwanceleri

Zip27z conversion using AutoIt3

Recommended Posts

Posted (edited)

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 3.3.14.5
+ 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).

 

Obiwanceleri

Zip27z_102.au3

Edited by obiwanceleri
Put warning in bold and red

Share this post


Link to post
Share on other sites

Note: There's a button to keep the console @SW_SHOW but it isn't implemented yet. When you show the console it will start hidden on the next file / process for the moment.

Share this post


Link to post
Share on other sites
44 minutes ago, obiwanceleri said:

PLEASE DON'T CONVERT ALL YOUR FILES YET. It's not fully tested (well I tested it but I need others to test too).

This important note/remark could be bold or even RED..... so I do this for you ;)

Thanks for script I will check it carefully.

btw.
:welcome:to the forum


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites
Posted (edited)

As I used to use:

Quote

AU3Check_Parameter=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

in AutoIt3Wrapper.ini

so I have to do small review.... please check this attached file (personaly I used to use WinMerge to compare files)

btw.
for now code looks good, but I not used it yet (before I run it, must check it deeply twice)

Zip27z_102.au3

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

Thanks mLipok! Tried the AU3Check parameters. For some reason -w 5 really didn't like _Width(). Claimed three of the four parameters weren't used so at the end of the procedure I did some bogus operations on them but Au3check didn't want to play ball. I think Au3check is confused since _Width() is called from a GUIRegisterMsg() call. 

In the end I fixed a stray $i in _7Z_COMPRESS() and took that -w 5 out.

 

Share this post


Link to post
Share on other sites
1 hour ago, obiwanceleri said:

For some reason -w 5 really didn't like _Width(). [...] ... and took that -w 5 out.

As you certainly know, the parameter -w 5 stands for "local var declared but not used".

During development I usually disable this parameter. It is not uncommon for more complex functions, that someone first declare the local variables without using them immediately. I activate -w 5 only for a final check to find and remove the unneeded ones.


Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Share this post


Link to post
Share on other sites

So today I decided to consider calling 7z.dll instead of calling the command line. I've been reading about it and it looks quite daunting. 

It does, however, give more control over how compression / extraction is going. 

I don't want to simply cut-and-paste. I want to understand how it's done. So there's going to be a lot of testing and poking in my future ...

Share this post


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 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  
    • By Scriptmaster
      <NEWBIE ALERT>
      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 TheSaint
      Here is a simple program that some of you might appreciate.
      It is a more full fleshed out version of something I worked on a while back as a proof of concept.
      I will just quote the information found in the Program Information dialog.

      Older Screenshot
      INItoSQL DB.zip
      INItoSQL DB v1.1.zip  (see Post #3 for update details)
      INItoSQL DB v1.4.zip  (see Post #4 for update details)
      INItoSQL DB v1.6.zip  (see Post #7 for update details) BIG THANKS to ResNullius for huge speed improvement etc.
      Program requires the sqlite3.dll, not included, but easily enough obtained.
      I have also included the beginnings of a new UDF (SimpleSQL_UDF) I am working, which you can use with the included 'Check conversion.au3' file to check a resulting conversion ... just modify the values for a few variables to suit your situation.
      I've not yet gotten around to coding a testing/checking results script, so I recommend the following open source program, which I have been using for some time. It was here, but is now here at GitHub - DB Browser for SQLite
    • 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
      Hello,

      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...