Professional Documents
Culture Documents
7-Zip Command Line Examples - All Syntaxes Shared Here
7-Zip Command Line Examples - All Syntaxes Shared Here
MENU
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.
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.
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:
[<file_names>…]
[<@listfiles…>]
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.
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.
7-Zip (A) 4.60 beta Copyright (c) 1999-2008 Igor Pavlov 2008-08-19
Scanning
Compressing fileA.txt
Compressing fileB.txt
Everything is Ok
C:UsersName>
Delete
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:
d: delete files
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
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
example.zip: the archive where you want to extract all the files from
List
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
Test
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:
Update
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
u: update command
There are several ways to use command prompt to unzip a file. The easiest
one is by using command prompt, unzip.exe command.
If you have a zip file, you may want to unzip it in the Command Prompt. The unzip
command lists the files inside the compressed archive and allows you to extract them.
This command is commonly found in MS-DOS and other operating systems. You can
use this command to extract multiple files at a time. It is important to remember that you
must enclose the wildcard *.zip in single quotes, otherwise the shell won’t recognize the
wildcard.
You must also set the timezone variable to reflect your timezone. You might need this
setting if you’d like to see the timestamps of the extracted files. Note that the WIN32
port gets its timezone configuration from the registry, so you should set it in the Control
Panel before using this command.
To create a zip file, start by selecting several files from the files folder in File Explorer.
Click the first file and then Ctrl+click the other files. Then, press the Enter key. You can
also zip multiple files at once. To do so, you must select all the files in the folder.
Another way to unzip a file is to change the option -aa to force the process to only
extract text files. Zip does not always correctly identify files that are text, so you can
make the process more effective by specifying a different flag. For example, if you have
a text file with spaces, you must make sure that aa is set to force it to be treated as text.
You may also use this flag in VMS to force the extraction of binary files.
ZIP files are widely used on the Internet. They save bandwidth and space. In addition,
they are secure. When zip files are sent, they can be encrypted to prevent the recipient
from gaining access to them. Unlike email, you can send many files at the same time
using a ZIP file.
Generally, unzipping a file in Windows 10 is quite straightforward and will not take long
at all. It is a simple process that you can complete on your own. Once you’ve done this,
you can open the Command Prompt and then navigate to the location where the file
was unzipped. Remember to restart your PC afterward.
Alternatively, you can unzip a file with the zip utility. You can also use a script to search
for files with the same extension. These scripts can be run from the command line and
can be used to unzip a file with ease. It is also possible to unzip a file using PowerShell,
which is more fiddly but has many benefits.
The path to the ZIP file must be exact. This means that the path to the ZIP file must
match the actual path on your PC. When it is complete, you can copy or paste the
extracted files into the destination folder.
Switches
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:
Switch Description
-bs{o|e|p}
Set the output stream for output/error/progress
{0|1|2}
-sni Store the NT security information
-sns Store the NTFS 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)
-stl Set the archive timestamp from the most recently modified file
-t Type of archive
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.
Use the “a” command to create a new archive file which can end in 7z, XZ, GZIP, TAR,
ZIP, and many more.
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.
Ramona
Jul 17, 2020 at 5:04 PM
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.
Ramona
Jul 17, 2020 at 5:16 PM
btw it would be even more helpful when the syntax and options of the switches
was explained somewhere, maybe with examples.
Reply
ineuw
Oct 7, 2020 at 5:20 AM
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???
Reply
Daniel
Mar 25, 2021 at 4:16 AM
the command 7z is followed by the "a" as a command to add files. The file /
exe is called 7z
It is helpful to add the path to 7zip in the PATH variable of the environment
variable.
By entering 7z (in the program path, or after configuring the PATH variable) in
cmd you get concrete information about the possible switches and the syntax.
For example, it is possible to delete the archived files via the -sdel switch.
Reply
Daniel
Mar 25, 2021 at 4:21 AM
(The form adapts the comment in a strange way and partially translates terms –
please check!!)
command 7z is followed by "a" as a command to add files to the archive. The file
/ exe is called 7z
by entering 7z (in the program path or after configuring the PATH variables) in
cmd you get sufficient information about the switches and the syntax.
For example, it is possible to delete the archived files via -sdel switch.
Reply
David
Mar 25, 2021 at 4:23 AM
Reply
Klaus
Jun 30, 2021 at 5:01 PM
I'm looking for a way to control splitting into partial files from the command line.
But I didn't find what I was looking for.
IDLBK
Apr 27, 2022 at 8:23 AM
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”.
Reply
Leave a Comment
Name *
Email *
Website
Post Comment
Start a Business: If you are planning to start an LLC, ZenBusiness is one of the top solutions for LLC
setup, read more about best llc services to learn more about the best llc services.
7ziphelp.com © 2022 - All Rights Reserved. All names, logos, images, and brands are property of
their respective owners.