How to compress and decompress files with PowerShell on Windows
Besides compressing and decompressing files with Winrar software, we can also compress and decompress files with Powershell. In today's article, we will learn how to do this extremely unique operation.
1. Compress files and folders with PowerShell
To compress files in the PowerShell file, we will use the following command:
Compress-Archive -Path file path, root directory -DestinationPath file path, destination directory
Inside:
file path, root directory: Is the file path, root directory with the file extension name.
file path, destination directory: Is the file path, compressed directory + compressed file/folder name that you set.
Step 1: You open PowerShell by going to the Search menu (1) => search with the keyword PowerShell (2) => Windows PowerShell (3).
Step 2: You enter the following command.
Compress-Archive -Path
Next, you can get the file path to compress by right-clicking on the file (1) => Properties (2).
Next, memorize the file address, file name (circled in red) or highlight the address and file name and press Ctrl + C to copy.
Then, you enter or paste (press Ctrl + V) the address and file name into PowerShell.
Step 3: Paste the command line behind.
-DestinationPath
Next, enter the destination folder address after extracting the file and insert the file name and press Enter to compress the file.
After done, the PowerShell command does not report an error.
Step 4: Then, you open the folder and check the compressed file.
Compressed file works fine and shows full archive as success.
2. Compress multiple files with PowerShell
Compress multiple files with PowerShell, use the following command:
Compress-Archive -LiteralPath file path 1, file path 2, file path n -DestinationPath directory path, compressed file
Inside:
file path 1, file path 2, file path n: is the file path you need to compress.
folder path, compressed file: is the path to the compressed folder + the file name you set.
Step 1: After determining the path and name of the compressed file to create.
Step 2: You enter the command with the syntax presented above to create the compressed file.
Step 3: You check the compressed file after completion.
If the compressed file works well and has enough files as you requested, it is successful.
3. Extract files with PowerShell
Step 1: To decompress the file in this way, the compressed file must be in .zip format. Next, you specify the file name and directory containing the file.
Step 2: You open PowerShell and execute the command with the following syntax.
Expand-Archive -LiteralPath archive path -DestinationPath destination directory path
Inside:
zip file path: Is the path to the compressed .zip file to decompress.
destination directory path: The path to the directory after extracting the file.
Step 3: You check the file after extracting.
If enough files and files work fine then success!
With basic and easy to follow instructions with the command line in PowerShell, you can perform compression and decompression of files in a unique way. Good luck!
You should read it
- How to install PowerShell 7.0 in Windows 10/8/7
- How to read text files in Powershell quickly and easily
- How to create files and folders easily with Powershell
- What is PowerShell Basic commands in PowerShell
- PowerShell command in Windows
- How to use PowerShell's default parameter to change the command behavior
- How to check PowerShell version in Windows 10
- Instructions on how to use PowerShell in Windows Server 2012
May be interested
- How to compress and decompress files with WinRAR on the computerusers of computers who can reduce the file size is the way to use winrar - compress files or folders to reduce data capacity. the following article details how to compress and decompress files with winrar on your computer
- 3 ways to compress and decompress files in Chromebookhere's how you can compress or decompress files on your chromebook with chrome os, third-party apps, and cloud storage.
- How to compress and decompress files with WinRAR on your computercompressing and decompressing files is one of the indispensable operations for computer users, especially when downloading or forwarding a file to another user. compressing files helps you reduce file size to the lowest level, helping to increase device memory. if you don't know how to compress and decompress rar, zip, etc. files with winrar, you can refer to the instructions in the article below and follow along.
- How to use NanaZip to compress and decompress files on Windows 10the nanazip application to decompress files on windows 10 has the same usage as decompression applications or software such as 7-zip or winrar software.
- 5 UWP applications compress and decompress, compact, free for Windows 10here are some uwp applications that can compress and decompress many formats on windows 10 and they are all free.
- How to compress and decompress files on iOSin this article, you will join tipsmake to find out how the file decompression feature works, but first you must update to ios 13 or later!
- How to compress and decompress files of all formats on your computerduring use, a large file is often restricted from sharing on social networks and takes a long time to download. in this case, compressing the file is the most effective way. so how to compress the file?
- How to install WinRAR, compress and decompress data files on your computerwinrar is software that supports effective file compression and decompression with many advanced features, supporting most popular compression formats. installing winrar is also quite simple, with just a few steps you can use the software to compress and decompress your files.
- How to use ZArchiver to compress and decompress files on Androidnot always android also allows you to open all kinds of files downloaded to your device, especially compressed files. if you regularly work with rar or 7z files, you will need to install a support app.
- How to decompress RAR, ZIP files with Winrar, 7-Zip softwareto compress zip and zip files, we can use winrar or 7-zip software, these are the two best file compression and decompression software currently. to decompress the file we first need to install winrar or 7-zip software on the computer. you can download these 2 software