# encoding: utf-8
import os.path
rootDir = '/data/log'
oldId = '.COMPLETED'
for parent, dirnames, filenames in os.walk(rootDir):
for filename in filenames:
if filename.find(oldId) != -1:
newname = filename.replace(oldId, '')
print(filename, "--->", newname)
os.rename(os.path.join(parent, filename), os.path.join(parent, newname))
os.system("pause")
递归重命名,保存一下