import os
import shutil
# 指定图片文件夹路径
image_folder = "/path/to/image/folder"
# 遍历该文件夹下的所有文件
for filename in os.listdir(image_folder):
# 获取文件的完整路径
full_path = os.path.join(image_folder, filename)
# 判断该文件是否是图片文件
if os.path.isfile(full_path) and filename.lower().endswith((".jpg", ".jpeg", ".png")):
# 将文件名从中文名改为指定名
new_name = "new_name_" + str(os.path.getctime(full_path)) + filename[-4:]
new_path = os.path.join(image_folder, new_name)
shutil.move(full_path, new_path)
Note that this script modifies all the picture names in the folder, among which
new_name_ is the name of the picture you want to change. The modified picture name is new_name_.95884.54646.bmp, and the numbers behind it are randomly generated
The dot in the middle is the usability symbol. If you want to make a yolo data set and there is no requirement for naming, this name can be read completely