Skip to content

Instantly share code, notes, and snippets.

@danielpclark
Created September 1, 2012 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpclark/3574571 to your computer and use it in GitHub Desktop.
Save danielpclark/3574571 to your computer and use it in GitHub Desktop.
This is 'supposed' to find all images without extension in the current directory and put the appropriate extension on them.
#!/usr/bin/env python
import os, imghdr
dlist = os.listdir("."+os.sep)
for x in dlist:
endr = imghdr.what(x)
endr = str(endr)
if endr == "None": continue
elif x[(len(endr)*(-1)):] == endr: continue
else: os.rename(x,x+"."+endr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment