Fix zip creation

This commit is contained in:
Patrick Jentsch 2020-04-04 15:37:29 +02:00
parent fa3b3cc556
commit 2952a274e4

View File

@ -37,11 +37,15 @@ def merge_images(input_dir, output_dir, output_file_base, zip):
cmd = 'rm "{}"/file_list.txt'.format(input_dir)
subprocess.run(cmd, shell=True)
if zip is not None:
# Remove .zip file extension if provided
if zip.endswith('.zip'):
zip = zip[:-4]
zip = zip if zip else 'output'
cmd = 'cd "{}"'.format(output_dir)
cmd += ' && '
cmd += 'zip'
cmd += ' -m'
cmd += ' "{}"_-_pdf "{}".pdf'.format(zip, output_file_base)
cmd += ' "{}" "{}".pdf'.format(zip, output_file_base)
cmd += ' && '
cmd += 'cd -'
subprocess.run(cmd, shell=True)