All pastes #728202 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-10-06 19:47 UTC
rendered paste body
import exif
import os
import time

DOIT = 0

times = {}
times["K750i"] = 0
times["HP PhotoSmart C945 (V01.60)"] = - (2400 + 68400)
times["DMC-TZ3"] = 86400
times["C750UZ"] = 148204800 + 3000
times["FinePix S5600"] = 3600
times["Canon PowerShot S3 IS"] = 3600

path = "C:/images/"

listim = os.listdir(path)
print listim
for image in listim:
    if image.find("JPG") != -1 or image.find("jpg") != -1:
        print path + image
        #print exif.parse("C:/images/" + image)
        try:
            model = exif.parse(path + image)["Model"]
            print '"' + model + '"'
        except KeyError:
            True
            
        try:
            model = exif.parse(path + image)["Camera Model"]
            print '"' + model + '"'
        except KeyError:
            True

        try:
            tdiff = times[model]
        except NameError:
            tdiff = 0
        except KeyError:
            tdiff = 0

        otime = exif.parse(path + image)["DateTimeOriginal"]
        oldtime = time.mktime(time.strptime(otime, "%Y:%m:%d %H:%M:%S"))
        newtime = oldtime + tdiff
        print "Old:" + str(time.ctime(oldtime)) + " New:" + str(time.ctime(newtime))
        if DOIT == 1:
            os.utime(path + image, (newtime, newtime))
        print "==========================================="