Horje
How to Compress or Extract files and folders using CMD?

If you work with large files on your Windows computer, then you need to know how to extract files and folders using the command prompt on Windows. You can manage your documents using the command prompt in just simple steps.

In this article, we will show you how to use basic command prompt commands to compress or extract files and folders. This method also helps in improving the efficiency of file transfer and also saves disk space. Follow the instructions below to keep your files safe.

Compress or Extract files and folders using CMD

Here are some straightforward ways to compress and extract files and folders using the Command Prompt on Windows, complete with a step-by-step guide.

How to Compress Files and Folders?

Let’s understand with two different methods how to compress any file and folder using the command prompt.

Method 1: Using Compact Command

Step 1: To compress files Click ‘Win + R’, type ‘cmd’ in the open box, and then press Enter.

Step 2: Next, change the directory to the target location using the cd command:

cd C:\Users\YourUsername\Documents

Step 3: After you have navigated to the directory where compression is needed, type the following command to compress a file:

compact /c filename.ext

Replace filename.ext with the name of the file you want to compress.

image-(2)

To compress an entire folder and its subfolders:

compact /c /s:directoryname

Replace directoryname with the name of the folder you want to compress.

Method 2: Creating a Compressed ZIP File Using Compress Command

Step 1: Open Command Prompt as Administrator.

Step 2: Use the Makecab Command:

First, list all files into a directive file:

dir /b /s *.* > list.txt

Step 3: Then compress the files listed in list.txt:

makecab /f list.txt

How to Extract Files and Folders?

Now, let’s check out with two different methods on how to extract any file and folder using the command prompt in no time.

Method 1: Using Expand Command

Step 1: Search for Command Prompt by either clicking on the Start menu or pressing Win + R. Type cmd, and then hit the Enter key.

Step 2: Use Expand Command:

Navigate to the location of your compressed file (.cab), Use the cd command to navigate:

cd C:\Path\To\Your\File

from there, you can make use of Expand Command.

expand filename.cab -F:* C:\DestinationFolder

Replace filename.cab with the name of your compressed file and C:\DestinationFolder with the path where you want the files to be extracted.

Method 2: Extracting ZIP Files using PowerShell

Step 1: To launch PowerShell, type that in the Start menu.

Step 2: Use the cd command to navigate to the location of the file:

cd C:\Path\To\Your\File

Step 3: Extract the ZIP file:

Expand-Archive -Path "C:\path\to\your\file.zip" -DestinationPath "C:\path\to\extract\to"

Replace "C:\path\to\your\file.zip" with the path to your ZIP file and "C:\path\to\extract\to" with the path where you want the files to be extracted.

These methods provide you with basic skills for compression and extraction using Command Prompt and PowerShell for files on Windows.

Conclusion

To put it simply, using the Command Prompt in Windows for file/folder compression or deletion is straightforward and efficient. This strategy is particularly valuable for handling large data sets economically. If you learn just a handful of basic commands like ‘’compact” and ”expand’’, you can reduce volumes of disk space and enhance your file organization. Employing these commands consistently will enhance your expertise and enable you exploit all the capabilities your Windows system offers.

How to Compress or Extract files and folders using CMD – FAQs

How do you compress and decompress files using the command line?

Linux and macOS terminals can be used to compress files through command line using the tar command: `tar -czvf archive.tar.gz /path/to/directory`. Decompress files with the command: `tar -xzvf archive.tar.gz` in a folder that you choose.

How to extract files using Command Prompt?

To extract files using Command Prompt, you should do the following: put ‘cmd’ in the Windows search bar and click “Enter” afterwards so that you open this window; move to where your zipped one is stored using “cd” command; In the end enter this command : `expand <filename>.ext -F:* <destination>` where needed directory should be specified.

Which command is used to extract?

Using Command Prompt on Windows to extract files requires use of the instruction called expand. It essentially decompresses files compressed through the Computer Find function available in its operating systems. Therefore, all you need is to type in `expand` after which include the address of the file or folder that is to be decompressed as well as where you want them extracted at.

How to extract multiple zip files at once using cmd?

To extract multiple ZIP files at once using the command prompt, first navigate to the directory containing the ZIP files. Then, use a for loop: `for %i in (*.zip) do “C:\Program Files\7-Zip\7z.exe” x “%i”` Ensure that 7-Zip is installed and correctly pathed in your system.

Which command is used to compress files?

Compressing files using Window’s Command Prompt uses the `compact` command to be able to do so. The NT Filesystem (NTFS) allows the `compact` command to reduce the size of the files. Usually, if a file needs compressing, you would do this by using the syntax compact /c filename.




Reffered: https://www.geeksforgeeks.org


TechTips

Related
How to set ANDROID_HOME path in Ubuntu? How to set ANDROID_HOME path in Ubuntu?
How to Enable/Disable Sticky Scroll in VS Code? How to Enable/Disable Sticky Scroll in VS Code?
How to Fix WiFi issue in Ubuntu? How to Fix WiFi issue in Ubuntu?
10 Ways to Track and Recover Your Lost/Stolen iPhone 10 Ways to Track and Recover Your Lost/Stolen iPhone
How to Fix Calculator App Not Working on iPhone? How to Fix Calculator App Not Working on iPhone?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
21