美文网首页
python对指定目录下的文件进行批量重命名的代码

python对指定目录下的文件进行批量重命名的代码

作者: fengqinyang | 来源:发表于2019-03-31 22:22 被阅读0次

    把开发过程较好的内容收藏起来,下面的资料是关于python对指定目录下的文件进行批量重命名的代码,应该是对大伙也有帮助。

    import os

    path = 'c:\temp'

    for file in os.listdir(path):

        if os.path.isfile(os.path.join(path,file))==True:

        newname = file.replace("scroll_1", "scroll_00")

            os.rename(os.path.join(path,file),os.path.join(path,newname))

            print(file)

    相关文章

      网友评论

          本文标题:python对指定目录下的文件进行批量重命名的代码

          本文链接:https://www.haomeiwen.com/subject/xydpbqtx.html