0%
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
import os
def rename(): name = "p"; count = 0; path = "F:\Pictures\Assets"
filelist = os.listdir(path) for files in filelist: Olddir = os.path.join(path,files) if os.path.isdir(Olddir): continue filename = os.path.splitext(files)[0] filetype = os.path.splitext(files)[1] Newdir = os.path.join(path,str(name)+str(count)+filetype) os.rename(Olddir,Newdir) count += 1 rename()
|
最终效果如图: