Python - 批量改变文件名

import os
import sys
import datetime

path = "E:\python_test"
datename = '2016-02-11'
a = datetime.datetime.strptime(datename,'%Y-%m-%d')

for (path,dirs,files) in os.walk(path):
for filename in files:
a = a + datetime.timedelta(1)
newname = a.strftime('%Y-%m-%d')+'_'+filename
os.rename(path+"\\"+filename , path+"\\"+newname)

posted @ 2016-03-02 13:24  西番莲果汁  阅读(212)  评论(0编辑  收藏  举报