Change system date of photos to EXIF date
It set the system datetime (both modifitation and access) to the date
the photo was taken.
It use the EXIF module for that, that needs to be in the same folder as the script :
You can find it here :
http://home.cfl.rr.com/genecash/digital_camera/EXIF.py
#!/usr/bin/python import sys import EXIF from datetime import * import time import os # Loop on arguments (files) for arg in sys.argv[1:] : # Do nothing of dirs if os.path.isdir(arg) : continue # Open the file f=open(arg, 'rb') # Read exif data tags = EXIF.process_file(f) # Ensure date is present if not tags.has_key("Image DateTime") : continue # Get date of photo date = tags["Image DateTime"] date = datetime(*(time.strptime(date.values, "%Y:%m:%d %H:%M:%S")[0:6])) timestamp = int(time.mktime(date.timetuple())) # Some traces print "File:%s - Time:%s " % (arg, timestamp) # Change the date os.utime(arg, (timestamp, timestamp))