www.7-zip.org

Taken from Help file

Command Line Syntax
7z <command> [<switch>...] <base_archive_name> [<arguments>...]

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

Expressions in square brackets (between '[' and ']') are optional.

Expressions in curly braces ('{' and '}') means that instead that Expression (including braces) must be used some string.

Expression

expression1 | expression2 | ... | expressionN

means that any (but only one) from these expressions must be specified.

Commands and switches can be entered in upper or lower case.

Command is the first non-switch argument.

The "base_archive_name" must be the first filename on the command line after the command.

The switches and other filenames can be in any order.

Wildcards or filenames with spaces must be quoted:

"Dir\Program files\*"
Dir\"Program files"\*

Switch options can be combined to save command line length. However, some switch options take optional string arguments and therefore, must be the last option in a combined argument token string because 7-Zip accepts the rest of the argument token as the optional argument.

7-Zip uses wild name matching similar to Windows 95:

'*' means a sequence of arbitrary characters.
'?' means any character.
Examples:

*.txt means all files with an extension of ".txt"
?a* means all files with a second character of "a"
*1* means all names that contains character "1"
*.*.* means all names that contain two "." means characters

The default wildcard "*" will be used if there is no filename/wildcard in command line.

Restrictions for wildcards and filenames for archiving files:

Wildcards and filenames can't contain disk name or network name. Every wildcard/filename path is treated as path from current directory on disk and as path from root directory in archive. In other words, the first part of path (letters before first slash ('\') symbol) always must be name or wildcard.
Wildcards and filenames can't be ended by slash ('\') symbol.
Wildcards can contain wildcard characters ('*' and '?') only in last part of path.
Examples:

Dir1\*.cpp OK
c:\Dir1\*.cpp ILLEGAL: path contains disk name
Dir1\Dir2\g?.txt OK
Dir1\D?r2\file1.txt ILLEGAL: there is a wildcard char in non last part

These restrictions do not act to filenames and directory names used not as archiving files.

List file
You can supply one or more filenames or wildcards for special list files (files containing lists of files). The filenames in such list file must be separated by space, tab or new line symbol(s). Wildcards or filenames with spaces must be quoted.

Multiple list files are supported.

For example, if contents of file "listfile.txt" is the following:

"My programs\*.cpp"
Src\*.cpp

then command

7z a -tzip archive.zip @listfile.txt

adds to archive "archive.zip" all "*.cpp" files from directories "My programs" and "Src".