Skip to content

Instantly share code, notes, and snippets.

@foolhorse
Created September 18, 2016 06:53
Show Gist options
  • Save foolhorse/5b9b74243085ce1e441ef7f917961b00 to your computer and use it in GitHub Desktop.
Save foolhorse/5b9b74243085ce1e441ef7f917961b00 to your computer and use it in GitHub Desktop.
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