Unrar List File Switch: Extract Specific Files

Extracting specific files from large RAR archives can become cumbersome when dealing with dozens or hundreds of distinct file paths. The unrar command-line utility addresses this by allowing you to supply an external text file containing a list of files to extract, rather than listing each item manually in your terminal command. This guide explains which switch to use and how to format your commands for targeted extraction.

The List File Indicator: @

In unrar, the primary method for specifying a list file containing items to extract is using the @ prefix directly before the path to the text file:

unrar x archive.rar @files_to_extract.txt

When unrar encounters an argument starting with @, it reads the referenced file and treats each entry inside it as a target file or wildcard mask to process.

Using the -n Switch with a List File

Alternatively, you can restrict extraction to files defined in a list using the include mask switch, -n:

unrar x -n@files_to_extract.txt archive.rar

The -n switch strictly defines which files to include. Prepending @ to the filename tells the -n switch to pull those inclusion patterns directly from the list file.

How to Format the List File

The list file must be a standard plain-text file formatted as follows:

  • Place each filename, path, or pattern on its own line.
  • Wildcard characters (such as * and ?) are supported.
  • Blank lines and lines starting with ; (comments) are ignored by the utility.

Example files_to_extract.txt:

document.pdf
images/*.png
data/reports/2023_summary.csv

Excluding Items Using -x@

If your goal is to extract the entire archive except for specific items specified in a file, use the exclude switch (-x) paired with the list file indicator:

unrar x -x@exclude_list.txt archive.rar