Skip to content

Instantly share code, notes, and snippets.

@brianbancroft
Created February 28, 2018 20:03
Show Gist options
  • Save brianbancroft/b6517448d89623d4069bb0ef08f3554f to your computer and use it in GitHub Desktop.
Save brianbancroft/b6517448d89623d4069bb0ef08f3554f to your computer and use it in GitHub Desktop.
Convert all jpg photos in ~/Desktop/photos to jpeg
import os
import re
regexp = re.compile(r'\.jpg')
folder = os.path.expanduser('~/Desktop/photos')
for filename in os.listdir(folder):
infilename = os.path.join(folder, filename)
if regexp.search(filename):
oldbase = os.path.splitext(filename)
newname = infilename.replace('.jpg', '.jpeg')
output = os.rename(infilename, newname)
@brianbancroft
Copy link
Author

Just copy and paste this into a python terminal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment