Advertisement
peter9477

scan folder for .jpg files that are really GIFs

Jun 8th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. import os
  2. import sys
  3. import glob
  4.  
  5. GIF_TAG = 'GIF'
  6.  
  7. try:
  8.     FOLDER = sys.argv[1]
  9. except:
  10.     FOLDER = '.'    # default to current directory
  11.  
  12. for path in glob.glob(os.path.join(FOLDER, '*.jpg')):
  13.     magic = open(path, 'rb').read(len(GIF_TAG))
  14.     if magic == GIF_TAG:
  15.         print 'File is really GIF', path
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement