Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
check image file type in current dir
#!/usr/bin/env python2
#-*-encoding:utf-8-*-
import os,sys
import imghdr
list = os.listdir('.')
for file in list:
filepath = os.path.join('.',file)
if os.path.isdir(filepath):
pass
else:
try:
print(imghdr.what(file) + ' '+file)
except TypeError:
print('TypeError'+ ' '+file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment