import os
import sys
rootdir = os.getcwd()
for (dirpath, dirnames, filenames) in os.walk(rootdir):
for filename in filenames:
testfile = os.path.join(dirpath, filename)
if (os.path.isfile(testfile) == True):
print(os.path.join(dirpath, filename))
#------------------------------
match_num = filename.find('-')
if (match_num == -1):
match_num = filename.find('.')
if (match_num != -1):
if (filename[:match_num].isdigit() == True):
newname = filename[match_num+1:]
os.rename(os.path.join(dirpath, filename), dirpath + os.sep + newname)
else:
print("不是000x开头")
else:
print("匹配失败")
#===========================================
print(">> NEW")
for (dirpath, dirnames, filenames) in os.walk(rootdir):
for filename in filenames:
testfile = os.path.join(dirpath, filename)
if (os.path.isfile(testfile) == True):
print(os.path.join(dirpath, filename))