数据压缩复制

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)

原文地址:https://www.cnblogs.com/gispathfinder/p/5710519.html