python批量重命名

import os

path = '/home/zqf/bridge/bdata/images/train'

original_name = os.listdir(path)
print(original_name)

for i in original_name:
filename=os.path.join(path,i)
savename = os.path.splitext(filename)[0]
savename=savename+".jpg"
print(savename)
os.rename(filename,savename)
print("OK")

posted @ 2022-12-29 17:49  阿风小子  阅读(70)  评论(0编辑  收藏  举报