Extract Multiple RAR Files in One Command Using Unrar
Extracting multiple RAR archives simultaneously in Linux or macOS
cannot be done simply by passing multiple filenames to the standard
unrar utility, as it interprets subsequent arguments as
specific files to extract or target directories. However, you can easily
process all your archives in a single command line by combining
unrar with standard shell features such as loops, the
find command, or xargs. This guide provides
direct, working one-line commands to batch extract RAR files quickly and
cleanly.
Choosing the Right Extraction Switch
Before running batch commands, select the appropriate switch based on how you want your files structured:
x(Extract with full paths): Recommended. Recreates the internal directory structure stored within the archive.e(Extract without paths): Dumps all contents directly into the target folder, ignoring any internal folder hierarchy.
Method 1: Using a Simple Bash Loop (Recommended)
The cleanest way to unpack every .rar archive in the
current directory is a one-line for loop. The shell
iterates through each file and runs unrar
independently:
for file in *.rar; do unrar x "$file"; doneTo extract all files into a specific destination directory (e.g.,
/path/to/destination/), append the folder path to the
end:
for file in *.rar; do unrar x "$file" /path/to/destination/; doneMethod 2: Using the
find Command
If your RAR archives are scattered across multiple subdirectories, or
if you prefer using standard Unix utilities, use find with
the -exec flag:
find . -maxdepth 1 -name "*.rar" -exec unrar x {} \;To search recursively through all subdirectories, remove the
-maxdepth 1 flag:
find . -name "*.rar" -exec unrar x {} \;Method 3: Using xargs
You can also pipe the list of files to xargs using the
-n 1 flag to ensure each archive is passed to its own
unrar process:
ls *.rar | xargs -n 1 unrar xHandling Multi-Part (Split) Archives
If your files are multi-part RAR sets (such as
archive.part1.rar, archive.part2.rar), running
unrar against every file will result in redundant
extractions and errors, because unrar automatically
extracts subsequent parts when given the first file.
To extract multiple multi-part sets in one command without errors, target only the first part:
for file in *.part1.rar; do unrar x "$file"; doneFor older naming conventions (e.g., .rar,
.r00, .r01):
for file in *.rar; do unrar x "$file"; done(The command will skip non-initial .rXX files
automatically when matching only .rar.)