#!/usr/bin/python
# coding=utf-8

#Copyright:     
#File:          rename_file.py
#Author:        Benny Wong
#Email:         
#Date:          2017-08-31
#Description:   批量重命名文件

import os
import io
import re

FILES_PATH = "files"

def RenameFiles(src, pattern, replace):
    for root, subdirs, files in os.walk(src):
        #文件
        for path in files:
            new = re.sub(pattern, replace, path)
            os.rename(root + "/" + path, root + "/" + new)
            print("%s rename to %s" % (path, new))
        break

# -------------- main --------------
if __name__ == '__main__':
    RenameFiles(FILES_PATH, "000", 'test_')
    os.system("pause")
