How to Extract Files Under a Certain Size with Unrar
Extracting specific files from a large RAR archive can save
significant disk space and processing time. The command-line utility
unrar provides built-in size filter switches that allow you
to unpack only items that meet your criteria. This guide explains how to
use the -sl switch to instruct unrar to
extract only files that are smaller than a specified file size.
The -sl Switch
The unrar command uses the -sl switch (Size
Less than) to set an upper file size limit. Any file inside the archive
with an uncompressed size equal to or greater than the specified value
will be skipped during extraction.
The basic syntax is:
unrar x -sl<size> <archive.rar> [destination/]x: Extracts files while preserving the original directory structure (useeif you want all matching files extracted into a single folder without subdirectories).-sl<size>: Specifies the maximum file size threshold.
Specifying Size Units
You can define the size threshold using standard unit suffixes
directly after -sl:
- Bytes (no suffix): Limits size strictly by byte count.
korK: Kilobytes (\(1\text{ KB} = 1,024\text{ bytes}\))morM: Megabytes (\(1\text{ MB} = 1,048,576\text{ bytes}\))gorG: Gigabytes (\(1\text{ GB} = 1,073,741,824\text{ bytes}\))
Note that there should be no space between the switch
-sl and the numerical value.
Practical Examples
Extract files smaller than 50 Megabytes:
unrar x -sl50m backup.rarExtract files under 500 Kilobytes into a specific folder:
unrar x -sl500k documents.rar /path/to/extracted/Extract files smaller than 100,000 bytes without directory paths:
unrar e -sl100000 data.rarPreviewing Files Before Extraction
To verify which files meet your size criteria before extracting them
to disk, you can use the list command (l or v)
combined with the same switch:
unrar l -sl10m archive.rarThis prints a table displaying only the files smaller than 10 MB, allowing you to confirm the contents without writing any data to your storage drive.