Hier ’ne feine Doku:
https://7-zip.opensource.jp/chm/
Inhaltsverzeichnis
Command Line Syntax
7z <command> [<switch>...] <base_archive_name> [<arguments>...]
<arguments> ::= <switch> | <wildcard> | <filename> | [@listfile] <switch>::= -{switch_name}
Expressions in square brackets (between ‚[‚ and ‚]‘) are optional.
Expressions in curly braces (‚{‚ and ‚}‘) mean that instead of that
Expression (including braces), the user must substitute 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.
7-Zip doesn’t use the system wildcard parser. 7-Zip doesn’t
follow the archaic rule by which *.* means any file. 7-Zip treats
*.* as matching the name of any file that has an extension. To process all files, you must
use a * wildcard.
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 at least „.“ characters |
The default wildcard „*“ will be used if there is no filename/wildcard in the
command line.
Slash (‚\‘) at the end of a path means a directory. Without a Slash (‚\‘) at
the end of the path, the path can refer either to a file or a directory.
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 new line symbol(s).
For list files, 7-Zip uses UTF-8 encoding by default. You can change encoding
using -scs switch.
Multiple list files are supported.
For example, if the file „listfile.txt“ contains the following:
My programs\*.cpp Src\*.cpp
then the command
7z a -tzip archive.zip @listfile.txt
adds to the archive „archive.zip“ all „*.cpp“ files from directories „My
programs“ and „Src“.
Short and Long File Names
7-Zip supports short file names (like FILENA~1.TXT) in some cases.
However, it’s strongly recommended to use only the real (long) file names.
Exit Codes from 7-Zip
7-Zip returns the following exit codes:
Code | Meaning |
---|---|
0 | No error |
1 | Warning (Non fatal error(s)). For example, one or more files were locked by some other application, so they were not compressed. |
2 | Fatal error |
7 | Command line error |
8 | Not enough memory for operation |
255 | User stopped the process |
Command Line Commands
The command is the first non-switch argument on the command line.
Command names are not case sensitive.
See also Command Line Syntax for more details about using the command line.
Commands quick reference
Command | Description |
---|---|
a | Add |
b | Benchmark |
d | Delete |
e | Extract |
h | Hash |
i | Show information about supported formats |
l | List |
rn | Rename |
t | Test |
u | Update |
x | eXtract with full paths |
Command Line Switches
Syntax
<switch>::= -<switch_characters>[<option>]
On the command line, a switch consists of a switch specifier,
either a dash (-) or a forward slash (/), followed by the name of
the switch. Switch names cannot be abbreviated.
Some switches take an argument after the switch name.
No spaces or tabs are allowed within a switch specification.
Switch names are not case sensitive, but arguments can be case sensitive.
Switch can be used in any place in command line.
See also Command Line Syntax for more details
about using the command line.
Noch keine Reaktion