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
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.Files or directories to add. Supports wildcards (* and ?). If omitted, adds files from current directory.
Set archive type: 7z, zip, gzip, bzip2, tar, wim, xz, etc.Example:
-t7z or -tzipSet compression level:
-mx0= Store (no compression)-mx1= Fastest compression-mx3= Fast compression-mx5= Normal compression (default)-mx7= Maximum compression-mx9= Ultra compression
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=2Set number of CPU threads for compression. Use
-mmt=on for all available threads.Example: -mmt=4 or -mmt=onSet password for archive encryption. Omit the password to be prompted.Example:
-pMySecretPass or -p (prompts for password)Enable archive header encryption (7z format only). This hides file names and structure.
Create multi-volume archives. Size can use suffixes: b (bytes), k (KB), m (MB), g (GB).Example:
-v100m (100 MB volumes)Recurse subdirectories. Include all files in subdirectories.
Exclude files by pattern. Can be used multiple times.Example:
-x!*.tmp -x!*.bakInclude files by pattern.Example:
-i!*.txt -i!*.docDelete files after compression (move to archive).
Compress files that are currently open/locked by other applications.
Set case-sensitive mode for file names.
Create self-extracting archive. Optionally specify SFX module.Example:
-sfx7zCon.sfxSet working (temporary) directory. Empty path means use system temp directory.
Read data from stdin. Optionally specify file name within archive.
Set archive timestamp from the most recently modified file.
Store hard links as links (not as separate files).
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