Execute Command for 7-Zip

Post Reply
magnussandstrom
Member
Posts: 24
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden

Execute Command for 7-Zip

Post by magnussandstrom » Tue Nov 03, 2020 1:56 pm

Hi, I'm trying to use Execute command in Switch to compress and encrypt files using 7-Zip command line program.

When I run the following command 7z a -tzip out.zip in.pdf in Windows Command Promt I get a successful ZIP-file. But in Switch I keep getting error code 1 (https://sevenzip.osdn.jp/chm/cmdline/exit_codes.htm).

The Command or Path is set to: C:/Program Files/7-Zip/7z.exe and the Argument is: a -tzip %1 %2

Any ideas what I'm doing wrong?

ps I'm going to use the XML Pickup for setting the password (but I left this out of the scope for now).
switch_1.jpg
switch_1.jpg (241.22 KiB) Viewed 400 times
switch_2.jpg
switch_2.jpg (79.66 KiB) Viewed 400 times
Tools at hand: Enfocus Switch, Esko Automation Engine, Esko Imaging Engine, Apogee Prepress, HP DFE, Fiery, Caldera, GMG ColorProof, PressSign, Redhat FUSE, Microsoft Azure and Google Cloud Services.

Zoranj
Member
Posts: 104
Joined: Tue Sep 20, 2016 7:37 pm
Location: Canada

Re: Execute Command for 7-Zip

Post by Zoranj » Tue Nov 03, 2020 9:39 pm

First swap %1 and %2 as 7zip needs output path first, than input so it is %2 %1
Also if you have any spaces in your path input or output, it is safer to put quotation marks around it so final commands look like:
a -tzip "%2" "%1"

I hope this helps.

magnussandstrom
Member
Posts: 24
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden

Re: Execute Command for 7-Zip

Post by magnussandstrom » Tue Nov 17, 2020 12:03 pm

I got help from Jan to solve this. The main issue was that 7zip creates the compressed file before populating it with compressed data. I use a set folder path instead of %2 and it solved the issue. The varible in my flow looks like this: a -tzip -scrcSHA256 "\\myfolderpath\[Job.NameProper].zip" "%1" -r -p[Job.PrivateData:Key="password"]

a = Add files to archive
-t = Output file type
-scrc = Encryption
-r = Recurse subdirectories
-p = Password

Background: I build this flow to encrypt and send sensitive files to clients etc. I let Switch generate the password and sending the password by SMS from Switch and the file URL by email. It's a really neat flow!

This is the Execute Command settings:
7zip.jpg
7zip.jpg (83.79 KiB) Viewed 207 times
Tools at hand: Enfocus Switch, Esko Automation Engine, Esko Imaging Engine, Apogee Prepress, HP DFE, Fiery, Caldera, GMG ColorProof, PressSign, Redhat FUSE, Microsoft Azure and Google Cloud Services.

magnussandstrom
Member
Posts: 24
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden

Re: Execute Command for 7-Zip

Post by magnussandstrom » Thu Nov 19, 2020 12:04 pm

And this is the finished flow:
flow.png
flow.png (116.91 KiB) Viewed 167 times
Tools at hand: Enfocus Switch, Esko Automation Engine, Esko Imaging Engine, Apogee Prepress, HP DFE, Fiery, Caldera, GMG ColorProof, PressSign, Redhat FUSE, Microsoft Azure and Google Cloud Services.

Post Reply