python3 批量替换文件名称
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "leo"
__time__ = "2018-05-17"
'''
批量修改文件名称
'''
import os
path = os.getcwd()
for file in os.listdir(path):
if os.path.isfile(os.path.join(path, file)) == True:
try:
# 替换文件名称 "abc" -> ""
new_name = file.replace('post\\德子\\', '')
os.rename(os.path.join(path, file), os.path.join(path, new_name))
except Exception as e:
pass
网友评论