把开发过程较好的内容收藏起来,下面的资料是关于python对指定目录下的文件进行批量重命名的代码,应该是对大伙也有帮助。
import os
path = 'c:\temp'
for file in os.listdir(path):
if os.path.isfile(os.path.join(path,file))==True:
newname = file.replace("scroll_1", "scroll_00")
os.rename(os.path.join(path,file),os.path.join(path,newname))
print(file)
网友评论