Use rar.exe in winrar
RAR command line syntax
~~~~~~~~~~~~~~
Syntax
RAR lt; command> [ -lt; switch>] lt; compressed file> [ lt; @list file...> [ lt;File...gt;] [ lt;Extraction path\gt;]
Description
Command line options (commands and switches) provided for creating and managing archives using RAR File control methods. Command
A command is a string (or a single letter) that instructs RAR to perform a corresponding operation. Switches are used
to change the way RAR performs operations. The other parameters are the archive name and the file to be compressed or to be extracted from the archive
.
The list file is a plain text file that includes the names of the files to be processed. The first column should start with the filename. You can
add a comment after the // character. For example, you can create backup.lst containing the following string:
c:\work\doc\*.txt //Backup text document
c:\work\image\ *.bmp //Backup pictures
c:\work\misc
Then run:
rar a backup @backup.lst
If you wish to read file names from the standard input device, specify an empty file list name (@ only).
Win32 Console RAR uses OEM (DOS) encoding in listing files.
You can specify a normal filename and a list file on the same command line. If neither file nor list
files are specified, then RAR will default to *.* to process all files
In a UNIX environment variable, you need to put the wildcard in in quotes to avoid expansion by the shell. For example,
This command will extract all *.asm files from the RAR archive in the current path:
rar e '*.rar' '*.asm'
The command can be any of the following:
a Add files to the compressed file.
Example:
Create or update an existing compressed file myarch, adding all files in the current directory
rar a myarch
c Add compressed file comments. Comments are displayed when the compressed file is processed. The comment length of the file is limited
to 32767 bytes
Example:
rar c distrib.rar
Comments can also be drawn from the file Add:
rar c -zinfo.txt dummy
cf Add file comments. Display file comments when using the 'v' command. File comments are limited to
32767 bytes.
Example:
rar cf bigarch *.txt
cw Write compressed file comments to the specified file.
Example:
rar cw oldarch comment.txt
d Delete files from a compressed archive. Please note that if this command causes all files
in the archive to be deleted, the empty archive will be deleted.
e Extract the file to the current directory.
f Update files in a compressed file. Update files that were changed after being packed into a compressed file. This command does not
add new files to the archive.
i[i|c|h|t]=lt; string gt;
Find the string in the compressed file.
The following optional parameters are supported:
i - case-insensitive (default);
c - case-sensitive search;
h - hexadecimal search;
t - uses ANSI, Unicode and OEM character tables (only available for Win32);
If no parameters are specified, it can use the simplified Command line syntax ilt; string gt; to replace
i=lt; string gt;
It allows specifying a 't' variable with another parameter, for example, ict=string performs a case-sensitive search in all tables mentioned above
.
Example:
1) rar "ic=first level" -r c:\*.rar *.txt
Compress in c:\*.rar *.txt files in the file perform a case-sensitive "first level"
string search
2) rar ih=f0e0aeaeab2d83e3a9 -r e:\text
Search for hexadecimal strings in rar compressed files in the e:\text directory
f0 e0 ae ae ab 2d 83 e3 a9.
k Lock compressed files. Any commands that attempt to alter the archive will be ignored.
Example:
rar k final.rar
l[t, b] Content list of compressed file [technical information]. Lists files like the 'v' command, but does not include the
file path. That is, only the file name is displayed. Optional technical information (main operating system, solid flag and old version flag) is displayed when using the 't' variable.
The variable 'b' forces RAR to output only plain
filenames without any additional information.
m[f] Move to compressed file [file only]. Moving files and directories will cause them to be deleted after the compression operation is complete.
If the variable 'f' is used and/or the switch '-ed' is applied, the directory is not deleted.
p Prints the file to the standard output device.
You can use this command with the -inul switch to suppress all RAR messages and print only
file data. This may be important when you need to send a file to the standard output device.
r Repair compressed files. Compressed file repair is done in two stages. First, search for recovery records in the corrupted archive (refer to 'rr' command). If the compressed file contains a recovery record, and
the damaged data part is contiguous and less than N*512 bytes (N is the number placed in the compressed file recovery block
) , the chances of successfully recovering the compressed file are very high. When this stage is completed, a new
archive will be created named _RECOVER.RAR.
If the corrupted archive does not contain a recovery record or if the archive is not fully recovered resulting in large
damage, the second phase will be executed. During this phase only the structure of the compressed file is reconstructed; files that failed the CRC check cannot be recovered. It is still possible to recover undamaged files due to file structure corruption. This is often useful for non-solid compressed files.
When the second phase is completed, the reconstructed compressed file will be saved as rebuilt.arcname.rar,
The location of 'arcname' is the original compressed file name.
RAR/DOS32 versions use _recover.rar and _reconst.rar instead of the
names mentioned above.
During recovery recording, RAR can prompt the user when suspicious files are found.
Suspicious items
Name: lt; Possible file name>
Size: lt; Size>
Add it: Yes/No/All
Answer 'y' to add this item to the file _RECOVER.RAR.
Example:
rar r buggy.rar
rc Use the recovery volume (.rev file) to rebuild the lost volume. You need to specify any existing volume as
the archive name, for example, 'rar rc backup.part03.rar'
Read the 'rv' command description to get information about the recovery volume information.
rn Rename compressed files.
The command syntax is:
rar rn lt; compressed file name gt; lt; source file name 1gt; lt; target file name 1gt; ... lt; source file name Ngt ; lt; target
target file name Ngt;
For example, the following command:
rar rn data.rar readme.txt readme.bak info.txt info .bak
In the compressed file data.rar, readme.txt will be renamed to readme.bak and
info.txt will be renamed to info.bak.
You can use wildcards in the source and target file names to perform name conversions as simple as changing the file extension
. For example:
rar rn data.rar *.txt *.bak
will rename all *.txt files to *.bak.
RAR does not check whether the target file name already exists in the archive, so you need to be careful to prevent
duplicate names. This is especially important when using wildcards. This command is potentially dangerous, since one incorrect wildcard can corrupt all compressed file names.
rr[N] Add data recovery record. Optionally, redundant information (recovery records) can be added to the archive
. This will cause the compressed file size to increase slightly, but can help recover the compressed file in the event of a floppy disk error or other data loss
. A recovery record contains a maximum of 524288 recovery blocks.
The number of blocks can be specified directly in the 'rr' (N = 1, 2.. 524288) command or does not need to be specified by the user.
It is automatically set according to the size of the compressed file. Guaranteed: A recovery message size is approximately 1 of the total compressed file size, which usually allows recovery of contiguous data up to 0.6 of the total compressed file size.
You can also specify the recovery record size as a percentage of the compressed file size. Just add
after the command parameters. For example:
rar rr3 arcname
Note that if you run this command from a .bat or .cmd file, you need to use rr3 instead of rr3 ??
Because the batch command uses the symbol '' as a parameter at the beginning of the batch file. You can
use 'p' instead of '', so 'rr3p' will also work.
If the damaged data is contiguous, each recovery record block helps recover 512
bytes of the damaged information. This value will be reduced if multiple locations are damaged.
The size of the recovery record can be estimated using the formula lt; compressed file size > / 256 lt; number of recovery records > * 512
Bytes.
rv[N] Creates a recovery volume (.rev file), which can later be used to reconstruct lost files in the volume group. This command is only sensitive to multi-volume compressed files. You need to specify the file name of the first volume file in the group.
For example:
rar rv3 data.part01.rar
This function can be used for backup, for example, to send a multi-volume compressed file to a new group , and
and some recipients did not receive some of the files. Resending the recovery volume instead of the normal volume can
reduce the total number of files transferred.
One lost RAR volume can be reconstructed per recovery volume. For example, if you have 30 volumes and 3 recovery volumes, you can create any 3 lost volumes. If the number of .rev files is less than the number of lost volumes, reconstruction will not be possible. The total number of normal and recovery volumes cannot exceed 255.
Option lt;Ngt; parameter specifies the number of recovery volumes to create, which must be less than the total number of RAR volumes. You can also
append a percent sign to this parameter, so that the number of .rev files created will be equal to the percentage obtained from the total number of RAR volumes.
For example:
rar rv15 data.part01.rar
RAR, whether using the 'rc' command or automatically, if the next volume cannot be located when decompressing, and
and a usable number of .rev files were found, attempts were made to rebuild both lost and damaged volumes.
The original copy of the damaged volume is renamed *.bad before being rebuilt. For example, volname.part03.rar
will be renamed to volname.part03.rar.bad.
s[name] Converts compressed files into self-extracting format. Compressed files are merged with self-extracting modules (using the
default.sfx module or specified in a switch). In the Windows version, default.sfx should
be placed in the directory where RAR.exe is located. In Unix, it should be in the user's home directory, in
/usr/lib or /usr /local/lib.
s- Remove the self-extracting module from an existing self-extracting archive. RAR creates a new archive without the self-extracting
module, the original self-extracting archive will not be deleted.
t Test compressed files. In order to verify the specified file, this command performs a virtual file decompression operation without writing any output data stream.
Example:
Test the compressed file in the current directory:
or for Unix:
rar t '*'
Starting from the current directory, test the compressed packages in all subdirectories:
rar t -r *
Or for Unix:
rar t -r '*'
u Update files in a compressed file. Add files that are not in the archive and update
files that have changed since packaging.
v[t,b] List the compressed file contents in detail [technical information]. The format used for file listing: absolute pathname, file comment, original and compressed size, compression ratio, last updated date and time, attributes, CRC,
The minimum RAR version required for compression and decompression. Optional technical information (main operating system, solid flag and old file version flag) is displayed when using the 't' variable. The variable 'b' forces RAR to output only plain
filenames without any additional information.
To list the contents of all compressed volumes, use an asterisk ('*') in place of the archive extension or use the '-v'
switch.
Example:
1) List the contents (technical information) of the system.rar compressed file and use the redirection character to output
to the file techlist.lst
rar vt system gt; techlist.lst
2) List the contents of tutorial.rar compressed file (simple file name mode)
rar vb tutorial
to the current path. AV inspection and annotation display are disabled.
Switches (used with commands):
-? Shows help for commands and switches. Same as when there are no parameters or illegal command line options are entered.
-- Stop switch scanning
This switch tells RAR that there are no more switches in the command line. It can be used if the archive or filename
begins with - symbol. Without the '--' switch, such names will be treated as switches
.
Example:
Add all files from the current directory to the solid archive '-StrangeName'
RAR a -s -- -StrangeName
-ac Clear archive attributes after compression or decompression (only available in Windows version).
-ad Append the compressed file name to the target path.
This option can be used when decompressing a group of compressed files. By default RAR places the files extracted from the archive
in the same directory, but this switch creates a separate directory for the files extracted
from each archive. directory.
Example:
rar x -ad *.rar data\
RAR creates a subdirectory under 'data' for each extracted file.
-ag[format]
Use the current date and time to generate the compressed file name.
Appends the current date string to the archive name when creating an archive. Used for daily backups.
Additional string formatting has several optional format parameters defined or uses "YYYYMMDDHHMMSS".
The format of the string can contain the following characters:
Y - Year
M - Month
MMM - Use a text string as Month name (Jan, Feb, etc.)
W - Week of the year (every week starts on Monday)
A - Day of the week (Monday-1, Sunday - 7)
D - Day of the month
E - Day of the year
H - Hour
M - Minutes (if after hours, treated as minutes)
S - Seconds
N - Number of compressed files. RAR searches for the existence of a file with the name to be generated, and if found
it already exists, the archive number is incremented until a unique name is generated.
Each string listed above represents only one character added to the compressed file name. For example,
Use WW to represent a 2-digit day of the week or YYYY to define a 4-digit year.
If the first character in the formatted string is ' ', the date string and the base archive name
are swapped, so the date will precede the archive name.
The format string can contain optional characters enclosed in '{' and '}'. This text is inserted into the compressed file name.
All other characters are added unchanged to the file name.
If you need to update an existing archive, use the -ag switch with caution. Depending on the format string passed with -ag previously
and the time, the generated and existing archive names may not match
. In this case RAR will create a new archive instead of updating the existing file.
Example:
1) Use the default YYYYMMDDHHMMSS format
rar a -ag backup
2) Use the DD-MMM-YY format
rar a -agDD-MMM-YY backup
3) Use YYYYMMDDHHMM format to replace the date before 'backup'
rar a -ag YYYYMMDDHHMM backup
4) Use YYYY-WW-A format, including section description
rar a -agYYYY{year}-WW{week}-A{wday} backup
5) Use YYYYMMDD and the number of compressed files. It allows you to use -agyymmdd-nn
several times in the same day, and each new archive name will contain a new incrementing number.
rar a -agYYYYMMDD-NN backup
-ao Add files with archive attributes
(Windows version only).
Example:
Add all files with archive attributes on C: to 'f:backup' and clear the file archive attributes
rar a -r -ac -ao f: backup c:\*.*
-ap Set the path inside the compressed file. When adding files to a compressed file, the path is integrated into the file name
and removed from the file name when decompressing.
For example, if you wish to add the file 'readme.txt' to 'DOCS\ENG' in the directory archive 'release'
, you can run:
rar a -apDOCS\ENG release readme.txt
Or unzip 'ENG' to the current directory:
rar x -apDOCS release DOCS\ENG\*.* p>
-as Synchronize compressed file contents
If this switch is used during compression, these compressed files that do not exist in the currently added file list will be compressed from the compressed file. Delete in.
It is convenient to use this switch in combination with -u (update) to synchronize the contents of a compressed file and the directory being compressed.
For example, after executing this command:
rar a -u -as backup sources\*.cpp
The compressed file 'backup.rar' will only contain *.cpp files in the directory 'sources', all other
files will be deleted from the archive. It is very similar to creating a new archive, but with one important difference: if no files have been modified since the most recent backup, this operation is performed faster than creating a new archive.
Be quick.
-av adds identity verification (only available in registered version). RAR will add information about the creator, last update time and archive name every time a new or updated archive is created
If a compressed file containing identity verification is modified without specifying this switch, the identity
verification information will be deleted.
When decompressing, testing, listing or updating archives using the '-av' switch, RAR will perform an integrity check
and display the message:
Verify identity information...
In case of successful identity verification, the message 'OK' is displayed, the creator's name and the most recent update
information are displayed. In case of authentication failure, 'Failed' will be displayed.
The user identity verification function, '-av', is recommended in software release environments.
In order to enable identity verification, the program must be registered. Please contact your local publishing point or website publishing center.
-av- Disable checking or adding authentication.
-cfg- Ignore configuration files and RAR environment variables.
-cl Convert file names to lowercase letters.
-cu Convert file names to uppercase letters.
-c- Suppress comments.
-df Delete files after compression
Move files to compressed files. This switch combined with command 'A' performs the same action as command 'M'
.
-dh opens shared files
Allows processing of files opened and written by other applications.
This switch is effective if the application allows read access to the file. But if the file's access type
is private, the file open operation will still fail.
This option is dangerous because it allows a file to be compressed while it is being modified by another application
so use with caution.
-ds Do not sort when adding to a solid archive.
-ed Do not add empty directories
This switch indicates that empty directories are not stored in the created archive.
When decompressing such an archive, RAR will create non-empty directories based on their internal file paths. Information about empty directories
is lost. All properties of non-empty directories except names (access rights, streams, etc.) are lost, so only use this switch if you don't need to preserve such information.
-ee does not handle extended attributes
Disables saving and repairing extended file attributes. Only available in OS/2 versions.
-en Do not add "End of archive" block
By default, RAR adds "End of archive" block at the end when creating or updating archives
Bundle" block. It allows skipping extended data like digital security signatures, but disabling these features may be useful under certain conditions
. For example, if a compressed file is passed between two systems over an unreliable connection, and the sender adds new files to it at the same time, it may not be correct. It is important to ensure that the part received during transmission will not be modified by the other end.
This switch cannot be used on volumes, since the archive end block contains important information for correct volume handling
.
-ep excludes paths from names. When this switch is included, the file will not include path information
when it is added to the archive. This may result in the presence of several files with the same name.
-ep1 Removes the underlying directory from the filename. Paths entered on the command line are not stored.
Example:
All files and directories in the tmp directory will be added to the compressed file 'test', but compressed
compressed file name path Does not contain 'tmp\'
rar a -ep1 -r test tmp\*
This is equivalent to the following command:
cd tmp
rar a -r ..\test
cd ..
-ep2 expands the path to a full path. The full path of the stored file during compression (except the drive letter and root directory path
).
The -ep3 extended path is the full path including the drive letter.
Only for Win32 version.
If this switch is used during compression, the full file path including the drive letter will be saved and restored. Disk partition
The separator (colon) is replaced by the underscore character.
If you use -ep3 when extracting, it changes the underscores back to colons and extracts the files to their
original directories and disks. If the user also specifies a target path, it is ignored.
This switch is useful for backing up several disks to the same compressed file.
For example, you can run:
rar a -ep3 -r backup.rar c:\d:\e:\
to create a backup and:
rar x -ep3 backup.rar
to restore it.
Use the -ep3 switch with caution and only if you are sure that the archive does not contain any malicious files. In other words, use it only if you created the compressed file yourself or if you completely trust its author. This switch
allows overwriting of any file anywhere on your computer, including important system files and
is generally used only for backup and recovery purposes.
-e[ ]lt;propertygt;
Specifies the exclusion or inclusion of masked properties files.
lt; attribute gt; Is the number format in decimal, octal (starting with '0') or hexadecimal (starting with '0x')
By default, in the
and the file's attributes is non-zero, the file will not be added
to the compressed file.
If the ' ' symbol is present, it specifies the inclusion mask. Only files with at least one of the
attributes specified in the mask will be added to the archive.
In the Windows version, D, S, H, and A can also be used instead of numeric mask symbols to represent the system, hidden, archive, and read-only attributes of directories and
files. The order of properties given is not important.
Unix versions support the D and V symbols for defining directory and device attributes.
Allows specifying both -elt;atrgt; and -e lt;atrgt; on the command line.
Example:
1) Only folder names without their contents
rar a -r -e d dirs
2) Do not compress system and hidden attribute files:
rar a -esh files
-f update files. Can be used when decompressing or creating compressed files. The command string "a -f" is equivalent to the command 'f'. You can also use '-f' with the command 'm' or 'mf'. If the '-f' switch is used with the 'x' or 'e' commands, only the old files will be replaced by the new versions extracted from the archive.
-hp[p] Encrypt file data and headers.
This switch is similar to -p[p], but the switch -p only encrypts the file data and makes other information such as the file name
visible.
This switch encrypts all compressed file-aware areas including file data, filename, size, attributes, comments and other blocks, so it provides higher security etc.
class. With -hp encryption in compressed files, it is not even possible to view the file list without the password.
Example:
rar a -hpfGzq5yKw secret report.txt
Will add the file report.txt to the encrypted compressed file secret.rar, using the password
'fGzq5yKw'
-id[c, d, p, q]
Disable message.
Switch -idc disables copyright strings.
Switch -idd suppresses display of the "done" string at the end of the operation.
Switch -idp disables percent indication.