Want to share a bunch of documents and folders all in one (without running the risk of forgetting one)? Looking to archive files in a manner that will save space and let you retire them to their original form reliably? Find out here how to create a ZIP file in Windows using File Explorer or the command line (PowerShell and command prompt).
First, a Prince or a Refrigerator
A frog may well be a prince, of course, or a refrigerator.
Where one folksy tradition has frogs turn out to be bewitched princes, another, in this case Russian, one says frogs will prevent milk from going bad. Their skin secrets peptides with antimicrobial properties, after all.
So, there is something to a frog acting as an inside-out refrigerator. With that in mind, let’s turn to archiving (and compressing) files with a metaphorical frog’s skin:
How to Create a ZIP File in Windows
Using Windows Explorer
Time needed: 2 minutes
To create a ZIP file that contains one or more files or folders in Windows using File Explorer:
- Open File Explorer in Windows.
Here’s how: Open the Start menu, for example, search for
file explorer
and choose it under Apps or Best match.
Windows keyboard shortcut: Press Windows E to open Explorer with a key combination. - Go to the folder that contains the files you want to compress into a ZIP file.
Here’s how: You can use the sidebar to navigate or type the directory path in the location bar (type Ctrl L to focus that bar).
- Highlight the files and folders you want to include in the ZIP file.
Here’s how: Use the mouse to draw an outline or click individual files to select them.
Add and remove: Hold down Ctrl while you click to add a folder to the selection or remove it from the selection.
“I want it all”: Press Ctrl A to select all files and folders in the current directory. - Click on one of the highlighted files or folder with the right mouse button.
Which to pick: Click on the one you’d like to use as the file name for the archive; see below.
- Select Compress to ZIP file from the context menu that has appeared.
More options: Choose ZIP file from Compress to… if Windows gives you more options; you can also choose the other compression methods, of course.
No “Compress to…”: If you do not see a Compress to menu item, select Send to | Compressed (zipped) folder from the context menu instead; this is true for Windows 10, for example, and when you select Show more options in the condensed menu. - Confirm or change the file name for the archive and press Enter.
Default: Windows will choose the name of the file or folder on which you right-clicked as the default (with a ZIP file extension).
Using a Command Prompt (PowerShell)
To compress files into a ZIP file using PowerShell on Windows:
- Open PowerShell.
Here’s how: Open the Start menu, start typingPowerShell
to search and select the PowerShell app. - Change to the folder that contains the files (and possibly folders) you want to zip up.
Here’s how: Typecd
followed by the path to the directory, then press Enter; you can use~
(tilde) to stand in for your user directory.
Example: Usecd ~/Downloads
, for instance, to go to your Downloads folder.
Dragging and dropping: You can typecd
, then drag and drop a folder from File Explorer. - Type
Compress-Archive -Path * -DestinationPath <filename.zip>
.
“Path”: Using the -Path parameter, specify which folders you want to include;*
selects all files and folders in the current directory,*.*
only the files in the current folder.
“DestinationPath”: Replace <filename.zip> with the name you want to use for the ZIP file.
Example: TypeCompress-Archive -Path * -DestinationPath ladedu.zip
to compress the current directory and all sub-folders (including the files in them) to a file called ladedu.zip.
More control: You can specify individual files to include with Compress-Archive using a variable. - Press Enter.
Create a TGZ File Archive Using the Windows Command Prompt
To archive files and folders to a Gzip-compressed (TGZ or TAR.GZ) file using the Windows command prompt:
- Open Command Prompt.
Here’s how: Search for and open Command Prompt in the Start menu. - Go to the folder that holds the files or folders you want to collect in a TGZ archive. (See above.)
- Type
tar -czf <filename.tgz> <files to compress>
.
Here’s why: The-c
option has tar create a new archive,-f
is followed by the desired name of the output file and-z
applies Gzip compression to the resulting file.
Example: Usetar -czf ladedu.tgz *
to compress all files and folders (including their files) to a file named ladedu.tgz. - Now press Enter.
How to Create a ZIP File in Windows: FAQ
Can Windows File Explorer open TGZ files?
Yes.
Windows Explorer will treat TGZ files just like ZIP files. You can double-click them to open them as a virtual folder or extract their contents using the context menu.
What are the other compression options in “tar”?
In addition to -z
for GZIP, tar offers these compression algorithms on Windows:
-j | bzip2 – uses the compression used in bzip2 – typically better compression than GZIP but slower |
-J | XZ – uses XZ compression from XZ utilities – usually results in the highest compression rate and smallest files |
--lzma | LZMA – uses LZMA compression from XZ utilities – similar to XZ, but in general superseded by the latter |
Windows File Explorer can open Gzip, bzip2 and XZ files. You can also extract from the compressed archives using tar on the command line, of course, with the following commands:
tar -xzf <archive file.tgz>
tar -xjf <archive file.tar.bz>
tar -xJf <archive file.tar.xz>
tar --lzma -xf <archive file.tar.lzma>
(How to create a ZIP file tested with Windows 11 Version 23H2; first published September 2024)