Do you need to extract ZIP files but don't want to use the mouse or open browser windows? If you prefer to work directly from the console or need to automate processes with scripts, unzip ZIP files from the command line. commands In Windows, it's a very useful skill. In this article, we'll explain all the possible ways you can do this, from using tools built into the operating system itself to third-party programs that extend its functionality.
Whether for practicality, technical necessity or simply curiosity, using the command console (CMD or PowerShell) to manage ZIP files can save you a lot of time on certain repetitive tasks. You'll see that you don't need to be an expert to achieve this, just know the right commands and how to apply them correctly.
What tools are available in Windows to unzip ZIP files using commands?
Windows, especially in its most recent versions like Windows 10 and Windows 11, has significantly improved its capabilities from the command line. Below, we show you the main ways you can work with ZIP files from the terminal.
1. Using the TAR tool in Windows 10 and 11
Since the April 2018 Update, Windows 10 includes the 'tar' command in PowerShell by default., which was previously exclusive to systems Unix o LinuxThis tool allows you to both compress and decompress files without having to install anything.
To unzip a ZIP file with tar, simply do the following:
tar -xf archivo.zip -C ruta\de\destino
Quick explanation:
- -x: indicates that it is going to be extracted.
- -F: specifies the file.
- -C: defines the directory where the files will be extracted (optional).
This command is ideal because it doesn't rely on external software and works quite well if you only need to perform basic extractions.
2. Using Windows Explorer from the command prompt
Another way to do this, although more indirect, is through commands that simulate file explorer actions. From Windows you can open and extract ZIP files automatically with the 'explorer' command.:
explorer archivo.zip
This opens the file as if you double-clicked on it. From there you can drag files or create a script to move the extracted files to another folder, although it is not the most practical for decompressing directly without user intervention.
3. 'Compact' command: limited but functional
Many users confuse the 'compact' command, believing it is for working with ZIP files. In reality, 'compact' is used to compress and decompress files on the file system NTFS, but it does not work directly with ZIP.
Still, it's interesting to know that you can compress or decompress files internally (not ZIP) with this command. To decompress, for example:
compact /u /s:ruta\carpeta
This removes previously applied NTFS compression using the modifier /u (uncompress). While this isn't what we're looking for when dealing with .zip files, it can be useful in other contexts.
Third-party utilities to unzip ZIP from CMD
In many cases, built-in tools don't offer the flexibility or advanced options you might need. Fortunately, there are free third-party programs such as 7-Zip, WinRAR, or Zipware which allow you to unzip files from the command line with many more options. For a more detailed comparison, you can check out 7-Zip vs WinRAR.
1. Unzip ZIP with 7-Zip from the terminal
7-Zip is one of the most popular and powerful programs for managing compressed files. It offers a simple graphical interface, but also You can use its 7z.exe executable from CMD to extract ZIP. You just need to have it installed and add its path to your PATH or specify it directly.
Usage example:
"C:\Program Files\7-Zip\7z.exe" x archivo.zip -oC:\ruta\de\extraccion
Options details:
- x: extract the contents of the ZIP file.
- -either: defines where to save the extracted files (no space after -o).
Additionally, 7-Zip supports multiple formats and high compression, making it great if you also need to compress efficiently. For more information on 7-Zip, see This article about 7-Zip.
2. Using WinRAR from CMD
WinRAR also allows work from the console using the unrar.exe fileThe basic command would be something like:
"C:\Program Files (x86)\WinRAR\UnRAR.exe" x archivo.zip C:\ruta\de\extraccion
However, please note that if you try to use the ZIP version of 'unrar.exe' it may not work properly. The tool focuses primarily on .rar files, although the application itself supports other formats from the graphical interface.
On some forums, such as Stack Overflow, several users have reported errors like "No files to extract" when trying to use 'unrar.exe' on ZIPs, so It is recommended to use 7-Zip or a specific alternative for ZIP. You can also check other applications for working with ZIP files.
3. Zipware: Another option for Windows
Zipware is perhaps less known, but it also allows Manage ZIP and other formats with options from their context menuWhile it doesn't have as much command-line support as 7-Zip, it's useful if you work from the graphical interface and want to automate tasks with PowerShell scripts combined.
Your options include:
- Extract to this folder: to save the content in the same place.
- Extract to a folder with the zip name
- Extract to another location: : if we need to organize them better.
Advanced Automation and Scripting with CMD
One of the great advantages of working with the command line is the possibility of create .bat or .cmd scripts to automate tasksIf you work in corporate or technical environments, this can help you save a lot of time.
Basic script example to unzip multiple ZIPs with 7-Zip:
@echo off
for %%f in (*.zip) do (
"C:\Program Files\7-Zip\7z.exe" x "%%f" -o"C:\extracciones\%%~nf"
)
This goes through all the ZIP files in the directory and extracts them into folders with the same name inside 'C:\extractions'. Ideal for processing large volumes of files without human intervention.
Frequently Asked Questions about ZIP and CMD in Windows
Can you extract a ZIP without installing anything extra?
Yes, you can use 'tar' or File Explorer from commands in Windows 10/11. Of course, these options are more limited.
What is the advantage of using 7-Zip from CMD?
Increased speed, advanced automation, and support for multiple formats. Ideal for professional or technical use.
Can I password protect a ZIP from CMD?
7-Zip allows it, but you have to specify it with the modifier -p. Example: 7z a -pcontraseña archivo.zip archivo.txt
What if I have file names with spaces?
Always enclose paths and names in double quotes: "C:\Mi Carpeta\archivo.zip"
The Windows command line has evolved more than many realize. Between native tools and third-party tools like 7-Zip, unzipping ZIP files from CMD is not only possible, but also fast, efficient, and practical. Whether you're automating tasks, working in environments without a graphical interface, or simply out of personal preference, the options Windows offers cover most needs. You can choose between built-in commands like 'tar' or more powerful solutions like 7-Zip, depending on the level of complexity you need to implement.
Passionate writer about the world of bytes and technology in general. I love sharing my knowledge through writing, and that's what I'll do on this blog, show you all the most interesting things about gadgets, software, hardware, tech trends, and more. My goal is to help you navigate the digital world in a simple and entertaining way.