下载了一些歌曲,其中有部分的名字是这样的 ”01.英雄谁属“
需要删除掉 ”01.”的前缀,手动改太麻烦,参考网络上的资料写了个python代码:
Python语言: Codee#26054
01 import os
02 path = "D:\\test"
03 for item in os.listdir(path):
04 old = item
05 if item[0].isdigit():
06 item = item[1:]
07 if item[0].isdigit():
08 item = item[1:]
09 if item[0] == '.':
10 item = item[1:]
11 print item
12 old = path + '/' + old
13 item = path + '/' + item
14 if old != item:
15 os.rename(old,item)
02 path = "D:\\test"
03 for item in os.listdir(path):
04 old = item
05 if item[0].isdigit():
06 item = item[1:]
07 if item[0].isdigit():
08 item = item[1:]
09 if item[0] == '.':
10 item = item[1:]
11 print item
12 old = path + '/' + old
13 item = path + '/' + item
14 if old != item:
15 os.rename(old,item)