官网:ExifTool by Phil Harvey
下载 Windows Executable 版本,解压即可得到exiftool(-k).exe
命令行使用^1
1 exiftool(-k).exe $FILE_PATH$
2. 读取拍摄日期 将exiftool.exe放在Python脚本同级目录下,使用os.popen()读取.RAF文件信息:
1 terminal_message = os.popen(rf'.\exiftool.exe {raf_path} ' ).read()
3. 批量重命名脚本 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 """ ==================================== @File Name: 001 rename_raf.py @Time: 2023/4/22 22:05 @Program IDE:PyCharm @Create by Author: 一一风和橘 @Motto: "The trick, William Potter, is not minding that it hurts." @Description: - RAF文件重命名,时间+文件名 ==================================== """ import osimport shutilimport tqdmPATH = r'J:\RAF' NEW_PATH = r'J:\RAF_copy' if not os.path.exists(NEW_PATH): os.mkdir(NEW_PATH) def get_date_original (raf_path ): terminal_message = os.popen(rf'.\exiftool.exe {raf_path} ' ).read() for line in terminal_message.split('\n' ): if 'Date/Time Original' in line: return line.split(' : ' )[-1 ].split(' ' )[0 ].replace(':' , '' ) assert 0 , 'Find No Date/Time Original' def run (): if not os.path.exists(NEW_PATH): os.mkdir(NEW_PATH) file_list = os.listdir(PATH) t_file_list = tqdm.tqdm(file_list) for file in t_file_list: if file == 'Desktop.ini' : continue t_file_list.set_description(file) raf_path = os.path.abspath(f'{PATH} /{file} ' ) pre = get_date_original(raf_path) new_dir = f'{NEW_PATH} /{pre} ' if not os.path.exists(new_dir): os.mkdir(new_dir) shutil.copy(f'{PATH} /{file} ' , f'{new_dir} /{pre} _{file.split("_" )[0 ]} .RAF' ) if __name__ == '__main__' : run()