a (add) command creates new archives or adds files to existing archives.
Syntax
Description
The add command is the primary method for creating archives. It can:- Create new archives
- Add files to existing archives
- Update existing files in archives with newer versions
- Create multi-volume archives
- Create self-extracting archives
- Apply compression and encryption
Common Options
string
required
Name of the archive to create or update. The archive type is determined by the file extension (e.g., .7z, .zip, .tar.gz) or by the
-t switch.string
Files or directories to add. Supports wildcards (* and ?). If omitted, adds files from current directory.
string
Set archive type: 7z, zip, gzip, bzip2, tar, wim, xz, etc.Example:
-t7z or -tzipnumber
default:"5"
Set compression level:
-mx0= Store (no compression)-mx1= Fastest compression-mx3= Fast compression-mx5= Normal compression (default)-mx7= Maximum compression-mx9= Ultra compression
string
Set compression method and parameters:
-m0=LZMA2- Use LZMA2 method-md={Size}- Dictionary size (16m, 32m, 64m, etc.)-mfb={N}- Number of fast bytes (5-273)-mmt={N}- Number of CPU threads
-m0=LZMA2 -md=32m -mfb=64 -mmt=2number
Set number of CPU threads for compression. Use
-mmt=on for all available threads.Example: -mmt=4 or -mmt=onstring
Set password for archive encryption. Omit the password to be prompted.Example:
-pMySecretPass or -p (prompts for password)flag
Enable archive header encryption (7z format only). This hides file names and structure.
string
Create multi-volume archives. Size can use suffixes: b (bytes), k (KB), m (MB), g (GB).Example:
-v100m (100 MB volumes)flag
Recurse subdirectories. Include all files in subdirectories.
string
Exclude files by pattern. Can be used multiple times.Example:
-x!*.tmp -x!*.bakstring
Include files by pattern.Example:
-i!*.txt -i!*.docflag
Delete files after compression (move to archive).
flag
Compress files that are currently open/locked by other applications.
flag
Set case-sensitive mode for file names.
string
Create self-extracting archive. Optionally specify SFX module.Example:
-sfx7zCon.sfxstring
Set working (temporary) directory. Empty path means use system temp directory.
string
Read data from stdin. Optionally specify file name within archive.
flag
Set archive timestamp from the most recently modified file.
flag
Store hard links as links (not as separate files).
flag
Store symbolic links as links (not as file contents).
Examples
Create a basic 7z archive
Create archive with maximum compression
Create password-protected archive with header encryption
Create ZIP archive with normal compression
Create multi-volume archive (100 MB volumes)
Add files with specific extension
Exclude specific files
Create archive and delete source files
Create archive with specific compression method
Create archive from stdin
Create self-extracting archive
Update existing archive
Create tar.gz archive (two-step compression)
Advanced Usage
Solid Archives
For maximum compression on similar files:Multiple CPU Threads
Use all available CPU cores:Custom Dictionary Size
Larger dictionary = better compression but more memory:When adding files to an existing archive, 7-Zip updates files that have been modified and adds new files. Use the
-u (update) command for more control over update behavior.Related Commands
- Update Command (u) - Update files with more options
- Extract Command (x, e) - Extract files from archives
- Delete Command (d) - Remove files from archives