#!/usr/bin/python # -*- encoding: utf-8 -*- # # exif-cp-datetime - Copies EXIF timestamps from a file to another # # Usage: exif-cp-datetime src.jpg dst.jpg [src2.jpg dst2.jpg ...] # # Copyright (C) Miguel Ángel Vilela # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. import pyexiv2 import sys DateTimeTags = ('Exif.Image.DateTime', 'Exif.Photo.DateTimeOriginal') # Parse arguments if len(sys.argv) < 3 or len(sys.argv) % 2 == 0: print "Usage: exif-cp-datetime src.jpg dst.jpg [src2.jpg dst2.jpg ...]" sys.exit(1) pairs = [(sys.argv[i], sys.argv[i+1]) for i in range(1, 2 + len(sys.argv) / 2, 2)] # Copy DateTimeTags from src to dst for src_name, dst_name in pairs: print "%s -> %s" % (src_name, dst_name), # src = pyexiv2.Image(src) # dst = pyexiv2.Image(dst) # src.readMetadata() # for tag in DateTimeTags; # dst[tag] = srd[tag] # dst.writeMetadata() print ""