没有目录结构的压缩文件夹

时间:2019-07-15 21:07:49

标签: structure

我正在尝试创建一个传递包,该传递包将从多个位置提取文件并将其添加到带日期的文件夹中,然后压缩带日期的文件夹。我得到的是一个带日期压缩的文件夹,但是它包含从根目录到带日期文件夹的整个目录结构。

我尝试了此处找到的解决方案,因为我认为其他用户也遇到了相同的问题,但似乎没有一个对我有用。我对此很陌生,一直在想办法,但是这让我很沮丧。 这就是我正在使用的

#Once all the files have been copied over zip them up.
zip_ready = 0   #default value

try:
    all_movie_files = os.listdir(delivery_dir)
    if len(all_movie_files) > 0:
        #First create a zip container
        zipname = '%s_delivery' % os.path.basename(delivery_dir)
        zip_file = os.path.join(delivery_dir,zipname)
        new_txt = ""
        for i in all_movie_files:
            zip_this = "/".join((delivery_dir,i))
            new_txt = new_txt+" "+zip_this
        zip_cmd = "zip "+zip_file+" "+new_txt
        server.log("debug","running cmd: %s" % zip_cmd)
        os.system(zip_cmd)
except Exception as e:
    msg = "ERROR creating zip file: %s" % str(e)
    server.log("error",msg)
else:
    #zip file was created
    zip_ready = 1

0 个答案:

没有答案
相关问题