How to Create ZIP Files With 7-Zip CLI
This guide explains how to generate standard ZIP archives using the 7-Zip command-line interface (CLI) instead of the default 7z format. You will learn the exact command-line switch required to define the archive type, the basic command syntax, and practical examples for compressing files and directories into ZIP files.
The Flag: -tzip
To create a .zip archive instead of the default
.7z format, use the -tzip
flag. The -t switch specifies the type of archive, and
appending zip instructs 7-Zip to format the output as a
standard ZIP file.
Basic Syntax
The standard command structure for creating a ZIP file is:
7z a -tzip <archive_name.zip> <file_or_folder_to_compress>a: The command to add files to an archive.-tzip: The switch that forces the archive format to ZIP.<archive_name.zip>: The name of the resulting archive file.<file_or_folder_to_compress>: The target files or directories to include.
Practical Examples
1. Compressing a Single File
To compress a single document into a ZIP archive:
7z a -tzip archive.zip document.pdf2. Compressing Multiple Files
To compress multiple specified files:
7z a -tzip archive.zip file1.txt file2.jpg file3.png3. Compressing an Entire Directory
To compress a folder and all of its contents:
7z a -tzip backup.zip ./my_folder/4. Setting the Compression Level
You can combine -tzip with the -mx flag to
define compression strength (from 0 for no compression up
to 9 for ultra compression):
7z a -tzip -mx9 archive.zip ./my_folder/