Python实现更改大量文件夹名称
想要实现文件夹名字从1-n,可以利用下面的代码:
(可以更改后缀)
import os
path='E:\\aLearn\\daiduan'
i=1
for file in os.listdir(path):
if os.path.isfile(os.path.join(path,file))==True:
new_name=file.replace(file,"%d.jpg"%i)
os.rename(os.path.join(path,file),os.path.join(path,new_name))
i+=1
print('End')
最后的结果如下图: