Featured image of post WinRAR Command Line Compression and Decompression Commands

WinRAR Command Line Compression and Decompression Commands

rar.exe is the command line version of WinRAR. It can be used for operations such as compressing, decompressing, extracting, testing, repairing, and creating multi-volume archives...

rar.exe is the command line version of WinRAR. It can be used for a variety of operations, including compressing, decompressing, extracting, testing, repairing, and creating multi-volume archives. The rar.exe file is located in the installation directory of WinRAR.

The command line format for rar.exe is as follows:

1
rar <command> [-<switch>] <archive> [<@listfile...>]

Command refers to the operation that rar.exe will perform. For instance, a means adding files to the archive, c means creating an archive, t means testing an archive, and x means extracting from an archive.

Switch controls how rar.exe executes the command. For example, -a means to add all files, -r means to add directories recursively, and -p means to display a progress bar.

Archive refers to the file or directory that you want to compress or decompress.

@listfile refers to a file that contains a list of files or directories to compress or decompress.

Example 1: Compressing Files

The following command compresses all files in the C:\test directory into a file named test.rar:

1
rar a test.rar C:\test

Example 2: Decompressing Files

The following command extracts the test.rar file into the current directory:

1
rar x test.rar

Example 3: Testing Files

The following command tests the test.rar file for corruption:

1
rar t test.rar

Example 4: Creating Multi-Volume Archives

The following command compresses all files in the C:\test directory into a file named test.rar, and creates multi-volume archives named test.r00, test.r01, etc.:

1
rar a -v test.rar C:\test

You can view all commands and switches for rar.exe by entering rar -h.

Here are some commonly used commands and switches:

Command Function
a Add files to the archive
c Create an archive
t Test the archive
x Extract from the archive
v Create multi-volume archives
e Extract specified files or directories
f Force extraction
p Display a progress bar
s Use solid compression
h Display help information

rar.exe is a powerful tool in WinRAR that can be used for various compression and extraction tasks. By learning its commands and switches, you can use rar.exe flexibly to accomplish a wide range of tasks.

Licensed under CC BY-NC-SA 4.0