list images split clas hang sdi dir ati
参考文章:http://www.cnblogs.com/ma6174/archive/2012/05/04/2482378.html
最近遇到一个问题,在网上下载了一批视频课程,需要将每节课的名称标号,方便排序观看,正好看了两天 python 语法,就想着用 python 实现一个简单的改名字的程序,果然有人已经做了,参考一下前辈的文章代码,差了点资料,就实现了一个简单的改名字的程序。
代码是参考前辈的,如有侵权请联系。
- # -*- coding: utf-8 -*-
- 'change file names automaticlly'
- import os
- filepath ='D://视频/法语/31~60'
- #filepath = 'D://视频/法语/11~30'
- #给每个文件名称开头添加数字序号
- forfilenamein os.listdir(filepath):
- list = filename.split(' ')
- temp = filename
- head =''
- forwordin list:
- ifword.isdigit() == True:
- ifint(word) > 10:
- head = word +' '
- newname = head + filename
- os.rename(os.path.join(filepath, filename), os.path.join(filepath, newname))
- print(newname)
最后的效果:
python 批量修改文件名称
来源: http://www.bubuko.com/infodetail-2032779.html