How to quickly check if a zip file is corrupted?

thuantta picture thuantta · Oct 17, 2010 · Viewed 35k times · Source

Does anyone have any ideas for how to pragmatically quickly check if a zip file is corrupted based on file size? Ideally the best way to check if a zip is corrupted is to do a CRC check but this can take a long time especially if there is a lot of large zip files. I would be happy just to be able to do a quick file size or header check.

Thanks in advance.

Answer

AzizSM picture AzizSM · Aug 22, 2017

Use zip -T to test the the file corrupted or not. Sample corrupted file look like this:

 zip -T filename.zip
        zip warning: missing end signature--probably not a zip file (did you
        zip warning: remember to use binary mode when you transferred it?)
        zip warning: (if you are trying to read a damaged archive try -F)

zip error: Zip file structure invalid (filename.zip)