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 26 27 28 29 30 31 32 33 34 35
| #!/usr/bin/python
# -*- coding:Utf-8 -*-
import os
import time
import xlrd
d = 'www/boite_noire'
myBook=xlrd.open_workbook('excel.xls')
mySheet=myBook.Sheet_by_index(1)
date = time.strftime('%Y_%m_%d_%H_%M_%S')
filesAll = os.listdir(d)
filesValid1= [i for i in filesAll if i[-4:]=='.txt']
for f in filesValid1:
newName = f[:-4]+'_'+date+'.txt'
try:
os.mkdir('{0}/{1}'.format(d, f[:-4]))
except:
os.system('mv {0}/{1} {0}/{2}/{3}'.format(d, f, f[:-4], newName))
filesValid2= [i for i in filesAll if i[-4:]=='.bin']
for f in filesValid2:
newName = f[:-4]+'_'+date+'.bin'
try:
os.mkdir('{0}/{1}'.format(d, f[:-4]))
except:
os.system('mv {0}/{1} {0}/{2}/{3}'.format(d, f, f[:-4], newName))
for(i=12,i<317,i++)
if(mySheet.cell(i,12)=f[:-4])
chassis=mySheet.cell(i,4)
os.rename(d+'/'+f[:-4],d+'/'+chassis) |
Partager