##### , , , spam001.txt,spam002.txt , ( spam001.txt spam003.txt, spam002.txt)。 , 。
import shutil, re, os
filedir = 'C:\\Users\\Loyu\\Desktop\\python1'
a = os.listdir(filedir)
alist = ' '.join(a)
span = re.findall('spam(\d+).txt', alist)
span.sort()
j = 0
lenlist = []
for i in range(1,len(span)+1):
newi = str(i)
newistr = newi.zfill(len(span[0]))
lenlist.append(newistr)
if span[i-1] != lenlist[j]:
shutil.move(filedir + '\\spam' + span[i-1] + '.txt', filedir + '\\spam' + lenlist[j] + '.txt' )
j += 1
print(' , spam' + str(lenlist) + '.txt ')