Way Compress and decompress files using Powershell on Windows 10/11 is an essential skill that every computer user should know. Powershell, a powerful command-line tool from Microsoft, not only helps you save storage space and simplify data management. In this article, AnonyViet will guide you how to use this tool to compress and decompress files effectively.
Join the channel Telegram belong to AnonyViet 👉 Link 👈 |
What is Powershell?
To explain simply, Powershell is a command line utility developed by Microsoft, created to replace CMD, helping users manipulate computers through commands. If you know how to use it, Powershell can help you save time in your work significantly.
While you can use File Explorer to quickly create a zip file or extract the contents of a compressed file, you can also use PowerShell to perform the same tasks more efficiently with the command line. Plus, you can even choose a compression ratio to compress the file faster.
See also: Instructions for creating Zip Bomb – Super compressed file that crashes the computer when opened
Instructions for compressing files using PowerShell
To zip files with PowerShell on Windows 10 (or 11), follow these steps:
Step 1: Open Start on Windows.
Step 2: Search for PowerShell, right-click the first result and select 'Run as administrator'.
Step 3: Type the following command to compress and zip a folder and press Enter:
Compress-Archive -Path C:\SOURCE\PATH\TO\YOUR\FILES\* -CompressionLevel Optimal -DestinationPath C:\DESTINATION\PATH\ZIPPEDFILE.zip
Note:
- Change C:\SOURCE\PATH\TO\YOUR\FILES\* to the folder path containing the files you want to compress.
- Change C:\DESTINATION\PATH\ZIPPEDFILE.zip into the path and name of the compressed file you want to create.
The * character acts as a wildcard, allowing all files inside the root directory to be compressed.
Instructions for adding files to a zip file using Powershell
Open Powershell, paste the following command in:
Compress-Archive -Path C:\SOURCE\PATH\TO\YOUR\FILES -Update -DestinationPath C:\DESTINATION\PATH\ZIPPEDFILE.zip
Change:
- C:\DESTINATION\PATH\ZIPPEDFILE.zip is the path to the existing compressed file.
- C:\SOURCE\PATH\TO\YOUR\FILES into the path to the files you want to add.
Instructions for changing the compression level for files
Access Powershell and use the command line as follows:
Compress-Archive -Path C:\PATH TO FILE YOU WANT TO COMPRESS\* -CompressionLevel Fastest -DestinationPath C:\WHERE TO SAVE FILE.zip
In there:
Select the desired compression level in the section -CompressionLevelsuch as:
- Fastest: Fastest compression, compressed file size may be larger.
- NoCompression: Uncompressed, compressed file size is equivalent to the total size of the original files.
- Optimal (Default): Compress with best compression ratio.
Instructions for unzipping files using Powershell
Type the following command to unzip a zip file and press Enter:
Expand-Archive -Path C:\PATH TO COMPRESSED FILE.zip -DestinationPath C:\WHERE TO SAVE FILE
Once the steps are completed, PowerShell will extract all files and folders from the specified zip file.
See also: How Install and activate Office 2024 LTSC free forever
Conclusion
By using these commands you can easily Compress and decompress files using Powershell on Windows 10 and 11, saving storage space and making it more convenient to manage and share data.