Blogger Information
Blog 34
fans 1
comment 0
visits 57098
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
重命名文件
Y的博客
Original
1124 people have browsed it

@Author   : 执笔画卿颜丶

@Date     : 2019/12/22

import os
path = r”{}”.format(‘请输入文件夹目录。提示:绝对路径!’)
try:
   os.path.isdir(path)
   for foldName, subfolders, filenames in os.walk(path):  # 用os.walk方法取得path路径下的文件夹路径,子文件夹名,所有文件名
       for filename in filenames:  # 遍历列表下的所有文件名
           news_name = filename.replace(‘【更多资料 www.itjc8.com】’, ‘【更多资料 study.llggo.com】’) # 替换的文件名称
           os.renames(os.path.join(foldName, filename), os.path.join(foldName, news_name)) # 开始替换
           print(“正在重命名:【{}】 文件.”.format(os.path.join(foldName, filename)))  # 输出提示
except:
   print(‘路径错误!请填写正确定的目录路径!’)

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post