7-Zip Command Line Examples — All Syntaxes Shared Here

7-ZIP command line tool version, 7z.exe, allows you to execute commands using the system terminal. 7-Zip is a powerful, open-source, and user-friendly program that offers support for most file archives like 7z, ZIP, RAR, TAR, and GZIp, among others. These characteristics make 7-Zip easy to download and be used for personal or commercial purposes.

7ZIP Command Line

By using the command-line version, you can access all features from the terminal even without a Graphical User Interface (GUI). Before we discuss any further about the different commands for 7-Zip, check out 7-Zip for more of our helpful guides.

Which is the best tool, 7-Zip vs WinRAR? Is 7Zip safe? These are some of the questions that you should also clarify before learning how to use 7Zip. You also need to understand the issues with 7-Zip cannot open file as archive that the tool sometimes experiences.

7-Zip can be used to compress, extract, test run-list, add, and update archive files. The 7z.exe version works with Windows, while 7-Zip is the command-line version for Linux, Mac OS X, and UNIX. The 7z format has several main features that include open architecture, high ratio, and secure AES – 256 encryption options. This software lets you use any compression or encryption method. The format supports file sizes of up to 16000000GB and Unicode file names. In the next section, we’ll be showing you some of the common commands that are used with this software.

Command Examples for Windows

The 7-Zip command-line executable file is the 7za.exe. You can use the EXE file to run commands on archives. In our examples, we’ll be using “C:UsersName” as our user directory. Below is a step-by-step guide to getting you started on the command line:

  • Before proceeding to other commands, one helpful tip is to place 7za.exe in your directory. This will give you convenience since you won’t have to change the environment paths.
  • Launch the Windows console and test the 7za.exe program out using a few commands
  • Type in the exe name, 7za, to display the file details

On the command line, the default command and output looks like this:

7za <command> [<switches>…] <archive_name>

Before we proceed with our examples, check out other guides, and reviews on our website. You might be interested in our 7-Zip vs WinRAR review and our 7-Zip password protect guide.

Function Letter Command

In this section, we’re going walk you through function letter commands. Because they are only single letters, they are quite easy to memorize.

Aside from looking for the details about 7-Zip download for PC or for Linux, it is important to have idea about archive error. Because the command line is useless if you don’t know how to fix 7-Zip cannot open file.

Archive and Add to ZIP

The function letter a command is used to put data in the archives. This “a” command stands for “archive” or “add.” To do this successfully, you must specify the archive location and the source files. Using the command will look like this on the terminal line:

C:UsersName>7za a -t7z files.7z *.txt
7-Zip (A) 4.60 beta Copyright (c) 1999-2008 Igor Pavlov 2008-08-19
Creating archive files.7z
Compressing fileA.txt
Compressing fileB.txt
Everything is Ok


The function letter d command is used for removing a particular file or files from an archive. This “d” command stands for delete. Using the command will look like this on the terminal line:

7z d example.zip *.bak -r

Let’s break down the command so you won’t get confused. The command stands for the following:

7z: use the executable file
d: delete files
example.zip: delete from this archive
*.bak: only match bak files
-r: traverse all subdirectories 

Extract and Enlarge

The function letter e command is useful when there is no substantial archive. The “e” command stands for extract to unzip or enlarge and archive. Using the command will look like this on the terminal line:

7z e example.zip

Again, let’s break it down to help you understand. In this command, we see the following words/commands:

7z: use the executable file
e: use the extract command
example.zip: the source archive you are expanding

Meanwhile, the function letter x command works the same way with e. The difference is it preserves the full paths. This is useful if you have an elaborate or important directory structure. Also, this is useful for backups. Using the command on the terminal looks like this:

7z x example.zip

In this command, we see the following words/commands:

7z: use the executable file
x: use the extract command
example.zip: the archive where you want to extract all the files from


This function letter lowercase L command is used to list the archive contents. The “l” command stands for list. However, you may not need to use this command it often. Using the command on the terminal looks like this:

C:UsersName>7za l files.7z


This function letter t command is used to test the integrity of archives. The “t” command stands for test. However, this is much less useful than the “-t” switch. Using the command on the terminal looks like this:

7z t example.zip *doc -r

In this command, we see the following words/commands:

7z: use the executable file
t: test the specific archive 
example.zip: the archive to be tested
*.doc: test all the doc files in the archive
-r: recurse all the child directories


This function letter u command is used to replace old files in your archive with newer files. The “u” command stands for update. This command prevents needing to decompress and recompress the entire archive. This command will not work with solid archives. Using the command on the terminal looks like this:

7z u example.zip *.doc

We see the following words/commands:

7z: use the executable file
u: update command 
example.zip: the archive you want to update files in
*.doc: only update the doc files

How Do I Unzip a File in Command Prompt

There are several ways to use command prompt to unzip a file. The easiest one is by using command prompt, unzip.exe command.

Unzipping a file might seem like a daunting task, especially for those new to using command prompt or the Windows operating system. However, with a little guidance and familiarity with a few basic commands, unzipping files in Command Prompt can become a simple and efficient process.

Command Prompt, also known as Cmd or the command line, is a powerful tool that allows users to interact with their computer directly through text-based commands. It provides a way to carry out various tasks, from managing files to executing advanced commands or scripts, and it can prove to be immensely helpful when it comes to file compression and extraction.

To start the unzipping process in command prompt, one must first locate the desired zip file on their computer’s directory. This can be achieved by navigating through the command line’s structure using commands such as “cd” or “dir”. Once the file is located, the next step is entering the appropriate command for unzipping.

While there are various types of compressed files, the most commonly used file extension for compression is “.zip”. To extract the contents of a zip file, the command “unzip” is typically used in Linux or macOS systems. However, in Windows, the command prompt does not have a built-in unzip function. But fret not, as there is still a straightforward way to unzip files using command prompt on Windows machines.

Windows utilizes the “expand” command to perform this task. By entering the “expand” command followed by the path of the zip file and the destination path, users can extract the contents of a zip file effortlessly. Additionally, including the “-F” flag with the command will allow overwriting of any existing files to ensure that the unzipped files are up to date.

For instance, to extract the contents of a zip file located on the desktop and have them placed in a specific folder, the following command can be used:

expand “C:\Users\Username\Desktop\compressed_file.zip” -F:* “C:\Users\Username\Documents\Unzipped”

This command will instruct the system to unzip the desired file and place all its contents in the designated folder. Furthermore, the “*.” symbol prompts the system to extract all the contents from the zip file, regardless of the file types.

It is important to note that mastering Command Prompt or any command-line interface may take a degree of practice and patience. However, once individuals embrace this proficient tool, they will uncover its immense potential in facilitating various tasks, including file compression and extraction.

In conclusion, unzipping files in Command Prompt might initially appear challenging. However, by acquainting oneself with a few simple commands and understanding the process, unzipping files can become a straightforward process in Windows. Although Windows does not have a native unzip function, the “expand” command enables users to effortlessly extract the contents of zip files through the command line interface. By following the right syntax and entering the appropriate command, individuals can unzip files to their desired destination without the need for third-party software, bolstering their efficiency and productivity.


Another command that we see on the command line is the switch. The switch is composed of a switch specifier and the name of the switch. The specifier is either a dash (-) or a forward slash (/). Switches often look like this:

Below is a list of common switches:

Switch Description
Stops switches parsing
-ad Shows dialog box in GUI version (7zg)
-ai Include the archive filenames
-an Disable the parsing of the archive name
-ao Overwrite mode
-ax Exclude the archive filenames
-bb[0-3] Set output log level
-bd Disable the progress indicator
-bs{o|e|p} {0|1|2} Set the output stream for output/error/progress
-bt Show the execution time statistics
-i Include the filenames
-m Set the compression method
-o Set the output directory
-p Set the password
-r Recurse the subdirectories
-sa Set the archive name mode
-scc Set the charset for the console input/output
-scrc Set the has function
-scs Set the charset for the list files
-sdel Delete the files after including it to the archive
-sfx Create the SFX archive
-si Read the data from StdIn
-slp Set the large pages mode
-slt Show the technical information
-sni Store the NT security information
-sns Store the NTFS alternate streams
-snc Extract the file as an alternate stream if there is : character in the name
-snr Replace : character to _ character in paths of the alternate streams
-snh Store the hard links as links (WIM and TAR formats only)
-snl Store the symbolic links as links (WIM and TAR formats only)
-so Write the data to StdOut
-spd Disable the wildcard matching for file names
-spe Eliminate the duplication of the root folder for extract archive command
-spf Use the fully qualified file paths
-ssc Set the sensitive case mode
-ssw Compress the files open for writing
-stl Set the archive timestamp from the most recently modified file
-stm {HexMask} Set the CPU thread affinity (hexadecimal number)
-stx Exclude the archive type
-t Type of archive
-u Update the options
-v Create the volumes
-w Set the working directory
-x Exclude the filenames
-y Assume Yes on all the queries

Frequently Asked Questions

???? How to use the 7-Zip command line?

Launch window and run the version of 7-Zip you are using by entering “7z” for P7Zip (7z.exe), or “7za” for 7-Zip in Windows (7za.exe) to either run the P7-Zip or 7za application before you enter commands. After that, you can use any of the commands listed above. Make sure that you’re following the syntax when typing in your commands.

???? How to extract with 7-Zip command line?

You can use the e or x commands to extract ZIP files.

???? How to create a 7-Zip file command line?

Use the “a” command to create a new archive file which can end in 7z, XZ, GZIP, TAR, ZIP, and many more.

???? How to zip a file using 7-Zip command line?

Use the “a” command to add files to the ZIP file.

7-Zip Command Line: Conclusion

Even without a GUI, you can use all the features of 7Zip on the command line. Just as long as you familiarize yourself with some of the commands, you’ll get better with practice. Did we miss any commands on our list? Let us know by leaving us a message in the comment section below.

7zip command line

8 thoughts on “7-Zip Command Line Examples — All Syntaxes Shared Here”

  1. Thanks for the guide, looks really helpful! Though I will need some practice before I can say that I can handle it well.
    However, maybe you should make one minor correction: The commandline tool in your guide is 7za.exe, but this executable can’t be found anywhere – which is quite confusing. Then I found it’s now just “7z.exe”, but that’s also a bit unclear on the download page.
    With this two minor adjustments, the guide would be great! 🙂

    • btw it would be even more helpful when the syntax and options of the switches was explained somewhere, maybe with examples.

  2. I agree with Ramona. Overall, the information is lacking from a simple user’s point of view. Insufficient examples on how to combine the switches. Please apply patience and write for ignorant users and with more examples.

    Does this mean “7za a -t7z files.7z *.txt” that -tzip would be the for a “zip” archive???

    • auf den Befehl 7z folgt das “a” als Befehl um Dateien hinzuzufügen. Die Datei / Exe heisst 7z
      Ein Befehl um zB Dateien eines Verzeichnisses hinzufügen kann so aussehen:
      7z a -t7z archivname.7z *.*

      Hilfreich ist es den Pfad zu 7zip in der PATH Variable der Umgebungsvariablen zu ergänzen.
      Dann könnt ihr 7z an x-beliebiger Stelle per cmd abrufen.

      mit der Eingabe von 7z (im Programmpfad, oder nach Konfiguration der PATH Variablen) in cmd erhaltet ihr konkrete Angaben zu den möglichen Schaltern und der Syntax.

      So ist es z.B. per -sdel Schalter möglich die archivierten Dateien dann zu löschen.

  3. (Das Formular passt den Kommentar auf komische Weise an und übersetzt teilweise Begriffe – bitte prüfen!!)

    auf den Befehl 7z folgt das “a” als Befehl zum Hinzufügen von Dateien in das Archiv. Die Datei / Exe heisst 7z
    Ein Befehl um z.B. Dateien eines Verzeichnisses hinzuzufügen kann so lauten:
    7z a -t7z Archivname.7z *. *

    Hilfreich ist es den Pfad zu 7zip in der PATH Variable der Umgebungsvariablen hinzuzufügen.
    Dann könnt ihr 7z an einer x-beliebiger Stelle per cmd abrufen.

    mit der Eingabe von 7z (im Programmpfad oder nach der Konfiguration der PATH Variablen) in cmd erhaltet ihr ausreichende Infos zu den Schaltern und der Syntax.

    So ist es zB per -sdel Schalter möglich die archivierten Dateien dann zu löschen.

  4. this comment function is unusable if it translates german to german – tried a second time – it too sounds ridiculous.

  5. Ich suche eine Möglichkeit, über die Kommandozeile das Aufteilen auf Teildateien zu steuern. Bin aber nicht fündig geworden.
    In der grafischen Oberfläche nennt sich das: “In Teildateien aufsplitten”

  6. Hello,

    Do you know if it is possible to use the CLI to extract the contents of a .exe file? The file that I am trying to extract can be opened by right-clicking the .exe file and choosing 7Zip – Extract and it properly extracts the contents of the archive. When I try to do it via the CLI I get an error saying “Incorrect Command Line”.

    Any suggestions would be greatly appreciated!


Leave a Comment