Created
April 27, 2015 00:53
-
-
Save dmd/6516a868231f53be3dcb to your computer and use it in GitHub Desktop.
flickr/bulkr fixer
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/python | |
import sys | |
import datetime | |
from dateutil.parser import parse | |
import os | |
import re | |
from pipes import quote | |
from subprocess import check_output, call | |
fn = sys.argv[1] | |
mdfn = os.path.splitext(fn)[0] + '.txt' | |
for line in open(mdfn,'r'): | |
if re.match("^Taken.Date", line): | |
# found the Taken line | |
break | |
if "Taken" not in line: | |
print("Taken date not found, aborting") | |
sys.exit(0) | |
taken = line.rstrip() | |
taken = taken.replace('Taken Date : ','') | |
exiftaken = (parse(taken).strftime('%Y:%m:%d %X')) | |
print (exiftaken) | |
print check_output (["exiftool", "-m", "-AllDates=\"{}\"".format(exiftaken), fn]) | |
# fix hemisphere. this doesn't hurt if it's right. | |
print check_output (["exiftool", "-m", "-tagsFromFile", fn, fn]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment