Skip to content

Instantly share code, notes, and snippets.

@akagisho
Created June 22, 2018 13:03
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 akagisho/6626aa24b9c321b9351684f0da76d84e to your computer and use it in GitHub Desktop.
Save akagisho/6626aa24b9c321b9351684f0da76d84e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import os
import stat
import datetime
import pyexiv2
argvs = sys.argv
argc = len(argvs)
if (argc < 3):
print 'Usage: python %s filename YYYY:MM:DD HH:II:SS' % argvs[0]
quit()
filename = argvs[1]
yyyymmdd = argvs[2]
if (argc == 3):
hhiiss = '00:00:00'
else:
hhiiss = argvs[3]
date = yyyymmdd.split(':')
time = hhiiss.split(':')
image_date = datetime.datetime(int(date[0]), int(date[1]), int(date[2]), int(time[0]), int(time[1]), int(time[2]))
img = pyexiv2.ImageMetadata(filename)
img.read()
img['Exif.Photo.DateTimeOriginal'] = image_date
img.write()
print img['Exif.Photo.DateTimeOriginal']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment