How to add a folder to 7z archive using 7za?
Asked Answered
C

1

7

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.

Choiseul answered 28/12, 2014 at 11:8 Comment(0)
C
15

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
Camiecamila answered 28/12, 2014 at 12:20 Comment(2)
what is -r parameter?Disguise
-r (Recurse subdirectories) switch Specifies the method of treating wildcards and filenames on the command line.Centesimal

© 2022 - 2024 — McMap. All rights reserved.