#!/usr/bin/python
# coding=UTF-8
import os, sys
from os.path import getsize
def renameFiles(rootDir):
lst = os.walk(rootDir)
for root, dirs, files in lst:
if len(dirs) !=0:
for dir in dirs:
subDir = os.path.join(root, dir)
renameFiles(subDir)
for file in files:
path = os.path.join(root, file)
for str in stripList:
if str in file:
print(file)
os.rename(path, os.path.join(root,file.strip(str)))
rootdir = r'D:\dirty\B'
stripList = [‘’]
renameFiles(rootdir)