How to Handle Spaces in File Paths with Unrar

When using the unrar command-line utility, file or directory paths that contain spaces will cause execution errors if not formatted properly, because the terminal interprets spaces as argument delimiters. To successfully extract an archive containing spaces, you must either enclose the paths in quotation marks or escape the space characters directly. This guide details the standard methods for handling spaces in unrar commands across Linux, macOS, and Windows.

The most reliable and portable way to handle spaces in both archive names and destination directories is to enclose the paths in double quotes ("). This tells the shell to treat the entire string as a single argument.

To extract with full paths:

unrar x "path to/my archive.rar" "destination folder/"

To extract directly into the current directory without preserving folder structure:

unrar e "path to/my archive.rar"

Quotation marks work across all operating systems, including Windows Command Prompt, PowerShell, macOS Terminal, and Linux shells.

Method 2: Escaping Spaces with a Backslash (Linux and macOS)

In Unix-like environments (Linux, macOS, and WSL), you can escape a space by preceding it with a backslash (\). This removes the space's default behavior as an argument separator.

unrar x my\ archive\ file.rar /home/user/extracted\ files/

This method is automatically generated when you use the Tab key for auto-completion in most command-line shells.

Important Considerations

  • Windows Path Trailing Slashes: When specifying destination paths in Windows Command Prompt, avoid placing a backslash directly before the closing quote (e.g., "C:\Target Folder\"). The shell may interpret \" as an escaped quotation mark, causing syntax errors. Instead, omit the trailing backslash:
    unrar x "C:\My Archives\file.rar" "C:\Extracted Files"
  • Multi-Part Archives: If you are extracting a split archive with spaces (such as .part1.rar or .r00), you only need to run the command on the first volume with quotes:
    unrar x "large backup.part01.rar"
    unrar will automatically find and process the subsequent parts without requiring you to list them individually.