mardi 1 décembre 2020

How to test and move a corrupt zip archive?

I have been searching everywhere and apparently no once has asked or I have not found a method to test a zip archive (or any archive for that matter) and if it is corrupt or just bad in some way... move it to a new location.

Using the 7z (windows 7-zip) GUI I can see a test window open up and gives a pretty good break down of the errored files... (I have no rep to post images)

What I don't understand is when using the 7z from CLI and trying to process out the error stream (7z.exe t -bse1 *.zip) it does not give me the same results as the GUI test window, but rather gives me all the good files tests as well. With 7z I am unable to find a good error code to attach some scripting around.

Using unzip on another system (unzip -t -qq '*.zip'), I can pump out a list off errored files, but I am still unable to get a solid error code, or even at a minimum a list of just the name of the bad archives.

What I would like: A script (windows or linux), that will test a folder full of zip archives, and if it finds a bad file (CRC, header corruption, whatever), it moves the archive to a BAD folder. The whole zip file gets moved to a BAD folder. I don't care if its repairable, and I don't want to hear all the million and one ways I could try and repair it.

What I would settle for: The ability to test a folder full of zip archives, and deliver a txt or log file that only has the name of the bad zip files in it.

example:

cat check.txt

archive01.zip
archive02.zip
archive03.zip
etc...

I can use that and wrap it in a "for in / mv" statement (for i in $(less check.txt); do mv "$i" /BAD; done)... or something along those lines.

There is a lot of garbage on the web and everyone wanting to show you how their program can repair your file. Again, I do not care and dont want to repair. I just want to test a large collection of zip archives, and move the bad ones to the side for possibly later review.

Thank you for ANY help you can provide!

Aucun commentaire:

Enregistrer un commentaire