UnRAR Switch to Overwrite Read-Only Files
When extracting RAR archives from the command line, existing files on
the destination path can halt the process or prompt for user
confirmation, especially if those files have read-only attributes. This
article explains which command-line switch allows unrar to
overwrite existing and read-only files automatically, details how it
works, and demonstrates how to apply it during extraction.
The Overwrite Switch:
-o+
The primary switch used in unrar to force overwriting
existing files—including read-only files—without prompting is
-o+.
By default, unrar asks for user permission before
replacing an existing file on the disk. Adding -o+
instructs the utility to proceed and overwrite any pre-existing files
matching the names of the files inside the archive.
Basic Syntax
To extract an archive with full directory paths and overwrite all existing files, use:
unrar x -o+ archive.rarTo extract all files directly into the current directory without
maintaining internal directory structures, use the e
command instead:
unrar e -o+ archive.rarHandling Interactive
Prompts with -y
In certain environments or older versions of the utility, read-only
attributes may trigger a separate permission confirmation dialog. To
ensure completely non-interactive extraction in automated scripts,
combine the overwrite command with the -y
switch:
unrar x -o+ -y archive.rarThe -y switch forces the utility to assume "Yes" to all
interactive queries, preventing scripts from hanging on file attribute
warnings.
Related Overwrite Switches in UnRAR
unrar provides several overwrite-handling options
depending on the desired behavior:
-o+: Overwrite all existing files unconditionally.-o-: Skip all existing files and do not overwrite anything.-or: Automatically rename extracted files if a duplicate exists on the destination path.