码迷,mamicode.com
首页 > 编程语言 > 详细

python 修改 文件名称

时间:2018-05-31 14:44:57      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:lower   box   nbsp   too   list   ram   atl   color   tla   

import os

def rename_func(path):
    for file in os.listdir(path):
        fileNew = file.lower()
        print("Old:", file, "New", fileNew)
        if(fileNew != file):
            os.rename(path + file, path + fileNew)

path2 = "C:\\Program Files\\MATLAB\\R2014b\\toolbox\\gatbx\\Test_fns\\"


rename_func(path2)

 

python 修改 文件名称

标签:lower   box   nbsp   too   list   ram   atl   color   tla   

原文地址:https://www.cnblogs.com/tangjicheng/p/9116345.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!