import os
def BatchRename(path):
if os.path.isfile(path):
print "file-->",path
if path.find("_MP3") == -1:
dotIndex = path.rfind('.')
fileName = path[ : dotIndex]
fileExt = path[dotIndex : ]
fileFullName = fileName + '_MP3' + fileExt
os.rename(path, fileFullName)
print (path + ' => ' + fileFullName)
elif os.path.isdir(path):
fileList = os.listdir(path)
for fileItem in fileList:
BatchRename(os.path.join(path,fileItem))
BatchRename('C:\\test')
文件批量重命名
最新推荐文章于 2024-12-16 14:14:37 发布