数据压缩复制

[亡魂溺海] 提交于 2020-01-04 15:51:39

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)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!