Created
May 6, 2018 21:34
-
-
Save tuxador/7f9d84ec045bc3d4da58edea86489bc9 to your computer and use it in GitHub Desktop.
script to rename photos by date using TIFF info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# rename and copy photos according to their EXIF date order | |
# needs exiv2 | |
import os, subprocess, shutil | |
fn = list(os.walk('.'))[0][2] | |
for f in fn: | |
if ('.jpg' in f or '.JPG' in f) and f[0] != '.': | |
cmd = ['exiv2', '-K', 'Exif.Photo.DateTimeOriginal', f] | |
r = subprocess.check_output(cmd) | |
r = r.decode("utf-8", "ignore") | |
r = r[60:].strip().replace(' ', '_') | |
f2 = "../sorted/" + r + "__" + f | |
f2 = f2.replace(':', '-') | |
print (f,f2) | |
shutil.copyfile(f, f2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment