Python-修改文件夹下所有文件的名字
2017-05-18 13:42
337 查看
import os def renameFile(): fileList = os.listdir(r"C:\Users\dell\Desktop\Udacity\prank\prank") print(fileList) # get current work path currentpath = os.getcwd() print("Current is "+currentpath) # change current work path os.chdir(r"C:\Users\dell\Desktop\Udacity\prank\prank") for fileName in fileList: print("Original is " + fileName) # delete 0123456789 in file name os.rename(fileName, fileName.translate(None, "0123456789")) print("Changed is " + fileName.translate(None, "0123456789")) os.chdir(currentpath) renameFile()
相关文章推荐
- python查找指定文件夹下所有文件并按修改时间倒序排列
- python查找指定文件夹下所有文件并按修改时间倒序排列的方法
- python自动化,读取文件夹内所有文件名字,并做简单的后缀名匹配
- python如何获取一个文件夹内包括子文件夹所有文件的名字和路径
- Python3基础 os listdir() 列举当前目录的所有文件及文件夹的名字
- 怎样通过DOS来提取一个文件夹下所有文件的名字
- 修改文件和文件夹的名字
- [C#]007_My007App_显示文件夹里所有文件的名字
- 获取指定文件夹下的所有文件+文件属性的获取与设置+文件夹属性的修改
- Python_删除/创建指定目录及其下所有子目录的文件,该文件记录当前文件夹的内容
- python列举文件夹下所有文件行数
- [python]抓取文件夹的所有文件,包括子文件夹和子文件夹的文件
- [python]抓取文件夹的所有文件,包括子文件夹和子文件夹的文件
- asp修改文件和文件夹的名字的代码
- Python_删除/创建指定目录及其下所有子目录的文件,该文件记录当前文件夹的内容
- python 获取文件夹下所有文件大小
- python列举文件夹下所有文件行数
- [C#]007_My007App_显示文件夹里所有文件的名字
- 用python查找指定格式或名称的文件及修改指定文件夹名称
- 文件夹下所有文件按修改时间 排序