Skip to content

Instantly share code, notes, and snippets.

@jimfilippou
Created February 6, 2018 21:17
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 jimfilippou/0239ab41182b54da64b712cae125dec1 to your computer and use it in GitHub Desktop.
Save jimfilippou/0239ab41182b54da64b712cae125dec1 to your computer and use it in GitHub Desktop.
Convert all PNGs to JPGs in current directory faaaaaaaast
import os
if __name__ == '__main__':
for subdir, dirs, files in os.walk(os.getcwd()):
for file in files:
x = os.path.join(subdir, file)
if x.endswith("png"):
# Convert image
print "Converting {}".format(x)
os.system("convert {0} {1}".format(x, x.replace("png","jpg")))
print "Deleting {}".format(x)
os.system("rm {}".format(x))
else:
print "Encountered unknown file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment