Checkframes utility

A little python utility to check that frames series you download from a render farm are okay (no frame missing, no frame with 0 byte size). Made on Linux, but should work on any platform. On Linux, place this script in your /home/$USER/bin folder (or any other that is in your $PATH), make it executable, then just run this script from a folder containing frames, or a folder containing subfolders. Enjoy!

#!/usr/bin/python#***************************************************************************#*                                                                         *#*   Copyright (c) 2012                                                    *  #*   Yorik van Havre                                  *  #*                                                                         *#*   This program is free software; you can redistribute it and/or modify  *#*   it under the terms of the GNU Lesser General Public License (LGPL)    *#*   as published by the Free Software Foundation; either version 2 of     *#*   the License, or (at your option) any later version.                   *#*   for detail see the LICENCE text file.                                 *#*                                                                         *#*   This program is distributed in the hope that it will be useful,       *#*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *#*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *#*   GNU Library General Public License for more details.                  *#*                                                                         *#*   You should have received a copy of the GNU Library General Public     *#*   License along with this program; if not, write to the Free Software   *#*   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *#*   USA                                                                   *#*                                                                         *#***************************************************************************"""This utility checks the current folder and any of its subfolders for jpg, pngor exr image sequences, numbered 0001.jpg, 0002.jpg, etc... and checks that noframe number is missing, and that no image is corrupted (sero-size)."""import os,sysfrom PIL import Image# keeping count of errorserrors = 0# getting working pathshomepath = os.path.abspath('.')subpaths = []for p in os.listdir(homepath):    ap = homepath + os.sep + p    if os.path.isdir(ap):        subpaths.append(ap)subpaths.sort()# add current path toosubpaths.insert(0,homepath)# checking framesfor p in subpaths:    print(" ")    print("checking folder "+p)    frames = []    for i in os.listdir(p):        if i[-4:].upper() in ['.JPG','.PNG','.EXR']:            frames.append(i)    if not frames:        print("    This folder doesn't contain frames")    else:        # counting frames and checking numbers        frames.sort()        try:            last = int(frames[-1].split('.')[0])        except:            print("    Error: couldn't parse frame numbers in this folder")            continue                    if len(frames) != last:            print("    Error: frame numbers differ from frames count in this folder:  last frame is "+str(last)+" but contains "+str(len(frames)))            ext = frames[-1].split('.')[1]            for i in range(1,last+1):                fn = str(i).zfill(4)+'.'+ext                if not fn in frames:                    errors +=1                    print("    Missing frame: "+fn)            # displaying info of first image        try:            imf =[0])        except:            print("    Error: cannot open image "+p+os.sep+frames[0])            continue        else:            print("    "+str(last)+" frames - format: "+imf.format+" - "+str(imf.size[0])+"x"+str(imf.size[1]))            # checking size        for f in frames:            fp = p+os.sep+f            s = os.path.getsize(fp)            if s < 1024:                print("    Error: zero-sized file: "+fp)                continue                        # subdir succeeded        print "    Everything ok"# all tests are doneprint(" ")if errors:    print(str(errors)+" errors found")else:    print("Success: All frames are ok")    sys.exit()