TheDcoder
TheDcoder

Reputation: 539

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.

Upvotes: 7

Views: 21663

Answers (1)

Mofi
Mofi

Reputation: 49097

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

Upvotes: 16

Related Questions