Unrar Password Switch for Multiple Archives
When extracting multiple password-protected RAR files simultaneously,
the command-line utility unrar utilizes the -p
switch to assign a default password across all targeted archives. This
parameter allows automated scripts and batch operations to unlock every
archive in the specified queue without pausing to prompt the user for
input during the extraction process.
The -p Switch
To supply a password to unrar, append the password
directly to the -p switch without any spaces:
unrar x -pMyPassword *.rarIn this command:
xinstructsunrarto extract files while preserving their original directory structure.-pMyPasswordsetsMyPasswordas the default decryption key.*.rartargets all RAR archives in the current working directory.
Syntax Rules and Batch Processing
When unrar runs a batch command involving wildcards
(such as *.rar), the value supplied to the -p
switch persists for every archive in that batch. If all archives share
the same password, the entire queue processes automatically from start
to finish.
Keep the following formatting rules in mind:
- No Space Between Flag and Password: The syntax must
be
-p<password>. Writing-p <password>with a space will causeunrarto interpret the password as a target archive name or another command parameter. - Special Characters: If your password contains shell
metacharacters, spaces, or symbols (such as
$,!,&, or spaces), enclose the password in quotes:unrar x -p"P@ss word!123" *.rar - Suppressing Prompts: If an archive within the batch
fails to decrypt with the provided password,
unrarwill typically halt and prompt you interactively. To strictly prevent interactive prompts and automatically skip incorrectly matched archives, you can combine the command with the-inul(disable messages) or batch mode settings in your environment.