标签:filename os.walk list odi new ack etc TE for
#!/usr/bin/env python
#coding:utf-8
import os
import shutil
import zipfile
dm_path = ‘/data/bz-tw-and‘
script_path = os.getcwd()
new_dm_dir = script_path+‘/bz_new/scripts‘
after_zip = ‘.zip‘
for (root,dirs,filename) in os.walk(script_path):
for file in filename:
if file[-4:] == after_zip:
zip_package = os.path.join(root,file)
z = zipfile.ZipFile(zip_package,‘r‘)
z.extractall(script_path+‘bz_new‘)
z.close
for qu_name in os.listdir(dm_path):
backup_dm = dm_path+‘/‘+qu_name+‘/‘+‘_scripts‘
now_dm = dm_path+‘/‘+qu_name+‘/‘+‘scripts‘
if os.path.exists(backup_dm):
shutil.rmtree(backup_dm)
os.rename(now_dm,backup_dm)
else:
os.rename(now_dm,backup_dm)
shutil.copytree(new_dm_dir,now_dm)
os.remove(now_dm+‘/Config.lua‘)
shutil.copyfile(dm_path+‘/‘+qu_name+‘/Config.lua‘,now_dm+‘/Config.lua‘)
标签:filename os.walk list odi new ack etc TE for
原文地址:http://blog.51cto.com/yht1990/2133459