from tkinter import filedialog, messagebox
import os
import csv
xlsPath = filedialog.askopenfilename(filetypes=[("Excel文件", "csv")], title="选择Excel文件")
picPath = filedialog.askopenfilenames(filetypes=[("照片", "jpg")], title="选择照片")
if not xlsPath or not picPath:
messagebox.showinfo("提示", "请选择需要修改的照片和csv文件!")
quit()
n = 0
with open(xlsPath)as f:
f_csv = csv.reader(f)
for row in f_csv:
picName = row[0]
picTime = row[1].split("/")[-1]
for p in picPath:
savePath = p.split("/")
if savePath[-1] == picTime:
savePath[-1] = picName + ".jpg"
savePath = "/".join(savePath)
os.rename(p, savePath)
n += 1
messagebox.showinfo("提示", "共替换%s张照片" % n)
批量修改外业精灵拍摄照片名称
最新推荐文章于 2024-04-18 22:26:05 发布