Skip to content
Advertisement

Python script to check if a zip file is corrupt

How do I check if a zip file is corrupt or not? I have a zip file with 10 jpg images. I am able to extract say 8 of the images. Two of the images in the zip are corrupt and I am not able to extract those. Is there a way to check for this in a Python script?

Advertisement

Answer

This code will either throw an exception (if the zip file is really bad or if it’s not a zip file), or show the first bad file in the zip file.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement