Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a folder to 7z archive using 7za?

I am having a bad time with the standalone version of 7-Zip. I want to compress a folder with a password. I tried: 7za a my_folder -pmy_password. It's compressing all the files in which 7za.exe is located with file name of my_folder.

BTW: I am using a scripting language called AutoIt.

like image 462
TheDcoder Avatar asked Dec 25 '22 00:12

TheDcoder


1 Answers

As per Command Line Syntax (7zip.chm) > Contents > Command Line Version > Syntax :

7za <command> [<switch>...] <base_archive_name> [<arguments>...]

<arguments> ::= <switch> | <wildcard> | <filename> | <list_file>
<switch>::= <switch_symbol><switch_characters>[<option>]
<switch_symbol> ::= '/' | '-' 
<list_file> ::= @{filename}

a is the command.

-pmy_password is a switch and should be therefore after the command and not at end. But switches can be also appended after base archive file name although this makes it more difficult to read and parse.

my_folder should be an argument, but is interpreted as base archive file name because you have not specified any archive file name.

So try:

7za.exe a -r -pmy_password MyArchive.zip my_folder
like image 143
Mofi Avatar answered Dec 28 '22 15:12

Mofi