修改文件名字

import os
import shutil
d=r'C:\appData\手机掌厅数据\导入IE\20180926\cut'
j=0
for i in os.listdir(d):
j=j+1
# newfilename = i.replace('jack','sesvc'),将文件名中“r0”替换成“r0_v2”
newfilename = i.replace('r0', 'r0_v2')
oldfullname = d+'\\'+i
newfullname = d+'\\'+newfilename
shutil.move(oldfullname,newfullname)
print(i+' 改成了:'+newfilename+' 第'+str(j)+'文件')
print('OK')

猜你喜欢

转载自www.cnblogs.com/c-w20140301/p/python.html
今日推荐