# -*- coding: Windows-1251 -*-
'''
rename_to_exiftime.py
Rename JPEG files according to EXIF-date using PIL
If global variable CREATE_HARDLINK is set, script creates Windows (XP) batch file
for creating hardlink version of source files
Author: Denis Barmenkov <[email protected]>
Modified by: Jorge Barnaby <[email protected]>
Improved rename process on duplicates
Copyright: this code is free, but if you want to use it,
please keep this multiline comment along with function source.
Thank you.
2009-02-10 18:14
'''
import Image
import os
import re
import sys
import time
CREATE_HARDLINK=0
def extract_jpeg_exif_time(jpegfn):
if not os.path.isfile(jpegfn):
return None
try:
im = Image.open(jpegfn)
if hasattr(im, '_getexif'):
exifdata &