批量修改文件名

批量修改文件名

废话不多说,直接上代码

import os
filenames = os.listdir(os.getcwd())  
for name in filenames:
    print(name)
for num in range(0,len(filenames)):
    if(num<10):
        print()
        print(filenames[num])
        os.rename(filenames[num],'0'+str(num)+'.png')
    else:
        os.rename(filenames[num],str(num)+'.png')