标签:filerename
最近下了《中国式英语口语纠错》里面的文件都是“tingvoa.com_cnusa043.mp3”,MP3播放器不识别,
因此用python脚本写了一个rename的脚本
# -*- coding: utf-8 -*-
import os
def filerename(path):
for file in os.listdir(path):
#print file
oldname = os.path.basename(file)
#tingvoa.com_cnusa043.mp3
print "oldname:",oldname
newname = oldname[12:]
print "newname:",newname
os.rename(os.path.join(path,file),os.path.join(path,newname))
if __name__ == "__main__":
path = u‘F:\\BaiduYunDownload\\中国式英语口语纠错‘
filerename(path)
标签:filerename
原文地址:http://blog.csdn.net/gaoxin12345679/article/details/25144879