Python Script to Detect Corrupt Image Files (.jpg)

Over the xmas period i  found out that most of the files in my documents folder were corrupt.  I didnt want to delete them all so i decided to see if Python could help and sure enough it did.

So i wrote a script below to;

  • find all images in a folder and sub-dir’s
  • open then with a python library and see if the file is corrupt
  • move them to a folder and rename them

Massive help from people on stackoverflow.com