更新
This commit is contained in:
parent
a126bb3490
commit
ace8089776
@ -36,10 +36,15 @@ def solution():
|
||||
|
||||
# 遍历照片文件并重命名
|
||||
for photo in photo_files:
|
||||
creation_time_stamp = get_photo_taken_time(folder_path+"\\"+photo)
|
||||
name = photo
|
||||
photo = folder_path+"\\"+photo
|
||||
creation_time_stamp = get_photo_taken_time(photo)
|
||||
if creation_time_stamp is None:
|
||||
continue
|
||||
if photo.startswith('IMG'):
|
||||
if name.startswith('IMG'):
|
||||
file_name, file_ext = os.path.splitext(photo)
|
||||
file_name = file_name[:-2]
|
||||
os.rename(photo, f"{file_name}.jpeg")
|
||||
continue
|
||||
formatted_time = "IMG_" + creation_time_stamp.values.replace(':', '').replace(' ', '_')
|
||||
file_name, file_ext = os.path.splitext(photo)
|
||||
@ -51,6 +56,7 @@ def solution():
|
||||
while os.path.exists(new_file_path):
|
||||
new_file_name = f"{formatted_time}-{index}{file_ext}"
|
||||
new_file_path = os.path.join(folder_path, new_file_name)
|
||||
index = index+1
|
||||
os.rename(photo, new_file_path)
|
||||
|
||||
print("照片重命名完成!")
|
||||
|
Loading…
Reference in New Issue
Block a user