数据压缩复制

path = u"H:\\data)"
outpath = u"H:\\output0"
current_files = os.listdir(path)
for file_name in current_files:

print(file_name)
dirname = path + "\\" + file_name + "\\DLG"
if not os.path.exists(dirname):
continue
os.mkdir(outpath + "\\" + file_name)
filelist = []
for root, dirlist, files in os.walk(dirname):
for filename in files:
filelist.append(os.path.join(root, filename))

#Start to zip file ...
fullzipfilename = outpath + "\\"+ file_name + "\\DLG.zip"
destZip = zipfile.ZipFile(fullzipfilename, "w")
for eachfile in filelist:
destfile = eachfile[len(dirname):]
print("Zip file %s..." % destfile)
destZip.write(eachfile, destfile)
destZip.close()

#os.mkdir(outpath + "\\" + file_name)

posted @ 2016-07-27 11:47  ParamousGIS  阅读(184)  评论(0编辑  收藏  举报