|
- import os
- import datetime as dt
- if not os.path.exists('excel存放'):
- os.mkdir('excel存放')
- for lujing,wenjianjia,wenjian in os.walk(os.getcwd()):
- for file in os.scandir(lujing):
- if file.name.endswith('xlsx'):
- data1 = dt.datetime.fromtimestamp(file.stat().st_mtime)
- newname = str(data1.year)+'-'+str(data1.month)+'-'+str(data1.day)+'-'+file.name
- os.rename(lujing+'/'+file.name,'excel存放/'+newname)
复制代码
|
|