"""Check the modified dates of files in the TDM pk4s. Look out for 1980 dates and 2088 dates.""" import os, fnmatch, zipfile PATH = r"C:\darkmod" results = { 'ok' : 0 } pk4counter = 0 filecounter = 0 for root, dirnames, filenames in os.walk(PATH): for filename in fnmatch.filter(filenames, '*.pk4'): pk4counter += 1 fpath = os.path.join(root, filename) f = zipfile.ZipFile(fpath, 'r') for member in f.infolist(): filecounter += 1 year = member.date_time[0] if year < 2000 or year > 2015: results[fpath + ' --> ' + member.filename] = member.date_time else: results['ok'] += 1 print "Results: Checked %d pk4s, found %d files" % ( pk4counter, filecounter ) print "Found %d ok files, %d problem dates\n" % ( results['ok'], len(results)-1 ) results.pop('ok') for k in sorted(results.keys()): print k, "%04d-%02d-%02d %02d:%02d:%02d" % results[k]