def setFileDates(fileName, dates):
  """Sets file modification and creation dates to the specified value"""
  try:
    import win32file, win32con
    filehandle = win32file.CreateFile(fileName, win32file.GENERIC_WRITE, 0, None, win32con.OPEN_EXISTING, 0, None)
    win32file.SetFileTime(filehandle, *(dates['exif'],)*3)
    filehandle.close()
  except:
    os.utime(fileName, (time.mktime(dates['exif']),)*2)
Sets file modification and creation dates to the specified value
recipes/Python/576822_Redate_pictures_with_EXIF/recipe-576822.py