Skip to content

Instantly share code, notes, and snippets.

@barosl
Created May 21, 2012 07:33
Show Gist options
  • Save barosl/2760954 to your computer and use it in GitHub Desktop.
Save barosl/2760954 to your computer and use it in GitHub Desktop.
Simple Exif manipulation script
HOURS_DIFFERENCE = 9 # can be negative
import os
import time
import datetime
import pyexiv2
for fname in os.listdir('.'):
if fname.lower().endswith('.jpg'):
print fname
fp = pyexiv2.ImageMetadata(fname)
fp.read()
for key in fp.exif_keys:
if 'Date' not in key: continue
tag = fp[key]
if not isinstance(tag.value, datetime.datetime): continue
tag.value = tag.value + datetime.timedelta(hours=HOURS_DIFFERENCE)
fp.write()
raw_input('Job finished.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment