def embed_xmp(filename, dt): t = calendar.timegm(dt.timetuple()) os.utime(filename, (t, t)) os.system('SetFile -d "%s" "%s"' % ( dt.strftime("%m/%d/%Y 00:00:00"), filename.encode('utf-8'), )) xmpfile = XMPFiles(file_path=filename, open_forupdate=True) xmp = xmpfile.get_xmp() xmp.set_property(consts.XMP_NS_XMP, "CreateDate", dt.isoformat()) if xmpfile.can_put_xmp(xmp): xmpfile.put_xmp(xmp) xmpfile.close_file() return True else: xmpfile.close() return False
def embed_xmp(filename, dt): t = calendar.timegm(dt.timetuple()) os.utime(filename, (t, t)) os.system('SetFile -d "%s" "%s"' % ( dt.strftime("%m/%d/%Y 00:00:00"), filename.encode('utf-8'), )) xmpfile = XMPFiles(file_path=filename, open_forupdate=True) xmp = xmpfile.get_xmp() xmp.set_property( consts.XMP_NS_XMP, "CreateDate", dt.isoformat() ) if xmpfile.can_put_xmp(xmp): xmpfile.put_xmp(xmp) xmpfile.close_file() return True else: xmpfile.close() return False