首页 > 其他 > 详细

批量重命名

时间:2017-11-28 16:16:33      阅读:173      评论:0      收藏:0      [点我收藏+]
import os
path = os.getcwd()
os.chdir(path)
file_name = os.listdir(path)
# print file_name

for each in file_name:
    if (‘WC‘ in each) and (‘WCT‘ not in each):
        name_rew = ‘WCT‘ + each[2:]
        os.rename(each,name_rew)
        print ‘%s rename to %s‘ %(each,name_rew)
    else:
        print ‘the file name is %s\t,don\‘t need to rename‘ %(each)

  

批量重命名

原文:http://www.cnblogs.com/hester/p/7910322.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!