Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of WinRAR Command Line version of rar.exe

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

RAR command line syntax

~

Grammar

RAR.exe [-] []

[] []

Common command

An add a file to the compressed file.

Example:

1) add all * .hlp files from the current directory to the help.rar zip file:

Rar a help * .hlp

2) if the directory contains a file mask or ends with a backslash, the general rule will be applied, and you need to specify the-r switch to handle its subdirectories.

The following command adds all files in the Bitmaps directory except for subdirectories, because no

Specify switch-r:

Rar a Pictures.rar Bitmaps\ *

D removes the file from the compressed file. Note that if this command causes all files in the file to be compressed

Delete all, and the empty compressed file will be deleted.

E extract the file to the current directory.

F updates the files in the compressed file. Update files that have been changed after being packaged into a compressed file. This order does not.

Add a new file to the compressed file.

U updates the files in the compressed file. Add files that are not in the compressed file and update the changed

Files.

M [f] is moved to a compressed file [for files only]. Moving files and directories will make it after the compression operation is complete

They were deleted. If you use the variable'f' and / or apply the switch'- ed', the directory is not deleted.

V [tmemb] details the contents of the compressed file [technical information]. The file lists the format used: absolute pathname, text

Item comments, original and compressed size, compression ratio, last updated date and time, properties, CRC

The minimum RAR version required for compression and decompression. Optional technical information when using the't 'variable (main operation

System, solid logo and old file version mark) display. The variable'b' forces RAR to output only simple

Without any other additional information

List the contents of all compressed volumes, use an asterisk ('*') instead of the compressed file extension or use'- v'

Switch.

Example:

1) list the contents of the system.rar compressed file (technical information) and use the redirector to output

To the file techlist.lst

Rar vt system > techlist.lst

2) list the contents of the tutorial.rar compressed file (file name only mode)

Rar vb tutorial

X-band absolute path decompression

Example:

Rar x test.rar testDir\

Note that the directory name is followed by a\ symbol. If there is no testDir folder, it will be created automatically.

If the file already exists, to unzip and overwrite the file, use the-o + switch, or use the-y switch. If not, use the-o-switch.

Common switch

-ag [format]

Generates a compressed file name using the current date and time.

Appends the current date string to the compressed file name when creating a compressed file. For daily backups.

The additional string format has several optional format parameters to define or use "YYYYMMDDHHMMSS".

The format of a string can contain the following characters:

Y-year

M-month

MMM-use a text string as the month name (Jan,Feb, etc.)

The week ordinal of W-year (each week begins on Monday)

A-what day is it (Monday-1, Sunday-7)

The day ordinal of D-month

Day ordinal of E-year

H-hour

M-score (if it is treated as minutes after the hour)

S-second

N-number of compressed files. RAR searches whether a file with the name to be generated exists, and if it is found

It already exists and will be incremented by a compressed file number until a unique name is generated.

The'N' format character is not supported when creating a volume.

Each string listed above represents only one character added to the compressed file name. For example

Use WW to represent a 2-digit week or YYYY to define a 4-digit year.

If the first character of the formatted string is'+', the date string and the basic compressed file name

The location is exchanged, so the date will precede the compressed file name.

Format strings can contain optional characters contained in'{'and'}'. This text is inserted into the press

Abbreviated file name.

All other characters are added to the file name unchanged.

If you need to update existing compressed files, use the-ag switch carefully. Rely on the past

Format string and time transmitted by-ag, generated and existing compressed file names can be

It doesn't match. In this case, RAR creates a new zip file instead of updating the current one.

There's a file.

Example:

1) use the default YYYYMMDDHHMMSS format

Rar a-ag backup

2) use 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 compress number of files. It allows you to use-agyymmdd-nn on the same day.

Several times, each new compressed file name will contain a new incremental number.

Rar a-agYYYYMMDD-NN backup

Note: the above command generates a zip file named backup {date string} .rar, and backup can also be another custom name.

To keep only the date in the file name, just write .rar instead of backup: rar.exe a-agYYYY-MM-dd .rar

-ed does not add empty directories

This switch indicates that the empty directory is not stored in the compressed file that was created. When decompressing such a pressure

When shrinking files, RAR creates a non-empty directory based on their internal file path. About empty directories

Donovan's information is missing. Non-empty directory in addition to the name (access rights, streams, etc.) All other attributes are complete

Part is missing, so use this switch only if you do not need to keep such information.

If-ed is used with the'm 'command or the-df switch, RAR will not be able to remove empty directories.

-hp [p] encrypts file data and headers.

This switch is similar to-p [p], but the switch-p only encrypts the file data and causes the file name, etc.

Other information is visible. This switch encrypts everything, including file data, file name, size, attributes,

All areas of compressed files are perceivable such as comments and other blocks, so it provides higher security, etc.

Class. Use-hp encryption in compressed files, and it's not even possible to view a list of files without a password.

Example:

Rar a-hpfGzq5yKw secret report.txt

Add the file report.txt to the encrypted compressed file secret.rar, using the password

'fGzq5yKw'

-m sets the compression mode:

-M0 storage does not compress the file when it is added to the compressed file.

-M1 fastest to use the fastest mode (low compression)

-m2 faster use of fast compression

-m3 standard uses standard (default) compression method

-M4 is better to use better compression (better compression, but slower)

-M5 is best to use maximum compression (the best compression, but the slowest)

If this switch is not specified, RAR uses-m3 mode (standard compression).

By default, RAR uses only regular compression algorithms in-M1 and-m2 modes, advanced algorithms

Like sound and true color processing are only enabled in-m3..-m5 mode, and enhanced text compression is only available

It is activated in-m4..-m5. The default value can be replaced with the-mc switch.

-ms [list]

Specifies the storage file type.

Specifies the type of file that is stored directly without compression. This switch is used to store compressed files.

This will help increase the compression speed without significantly reducing the compression ratio.

Optional parameter parameters define a list of file extensions separated by semicolons. For example,

-msrar;zip;jpg will force RAR to store all RAR and ZIP compressed files and files directly without compression

JPG image. It also allows wildcard file masks to be specified in the list, so-ms*.rar

*. Zip;*.jpg can also work.

If not specified, the-ms switch uses the default extension that contains the following file types

Exhibition settings:

7z, ace, arj, bz2, cab, gz, jpeg, jpg, lha, lzh, mp3

Rar, taz, tgz, z, zip

-mt

Sets the number of threads. Available only for the Window version.

Parameters can be values from 0 to 16. It defines the value of the

Recommended number. If it is greater than 0rar, the multithreaded version of the compression algorithm will be used in multiprocessing.

Higher speed is provided on the device system. The actual number of active threads may be different from the specified one.

If it is 0primeRAR, it will use the single thread compression algorithm.

Changing the parameters slightly affects the compression ratio, so if all other compression parameters are equal and

Compressed files created with different-mt switches will not be unzipped as coherently.

If the-mt switch is not specified, RAR attempts to detect the number of processors available and automatically

Select the number of threads to optimize.

-or automatically renames the extracted file if a file with the same name already exists. Renaming the file will get

To a name like 'filename (N) .txt', the location of 'filename.txt'' is the original file

Name, if the file exists'N' is to increase the number from 1.

-o [+ | -] sets the override mode. Can be used when extracting or updating files. The following modes are available:

-O ask before overwriting

(default is used to extract files)

-o + covers all

(default for updated compressed files)

-o-Skip existing files.

-o + overwrites existing files.

-o-do not overwrite existing files.

Use strings when compressing-p [p]

Encrypt the file as a password. The password is case sensitive. If you're here,

The command line ignores the password and you will see a prompt to enter the password.

Example:

Rar a-pmyhoney secret1 * .txt

Add * .txt file and encrypt it with password "myhoney".

-r contains subfolders, and you can use the command:

A recalcitrance uperior frecinct m recorder x recorder e recorder treco p recorder v recorder l recorder cf and s.

When you use the command 'axiomaginthecontrol, fuzz', it will be processed in all subdirectories as well as the current work item

The file in the recording.

When using the command xmeme _ rep _ r _ p _ r _ r _ c _ f or s will be processed in the subdirectory as well as the current worker.

Make all the compressed files in the directory.

-r-disables recursion.

In some cases, recursion is automatically enabled even if the-r switch RAR is not specified. Switch-r-

Forbid it.

If you specify a directory name during compression, the directory name does not contain wildcards, even if the-r switch is not specified

The default RAR adds the contents of the directory. If the disk root does not specify a wildcard as a file mask

RAR also automatically enables recursion. Switch-r-disables this behavior.

Example:

Rar a-r-arc dirname

The command simply adds the empty directory 'dirname' directory and ignores its contents. The following commands:

Rar a-r-arc c:\

Only the contents of the c: root directory will be compressed and will not contain subdirectories.

-ta

Only files modified after the specified date are processed.

The format of the date string is YYYYMMDDHHMMSS. It allows you to insert'-'in the date string.

Or the delimiter of': 'and ignores the rear area. For example, the following switches are correct:

-ta2001-11-20 internally it is converted to-ta20011120000000 and used as "from 2001"

Areas modified after 00:00:00 on November 20, 2008 are treated.

-tb

Only files modified before the specified date are processed. The format of the switch is the same as-ta.

-tn

Process new files after the specified time. When in time string format:

[d] [h] [m] [s]

For example, use the switch-tn15d to process files that have been updated for 15 days, and-tn2h40m to handle more

The file is new for 2 hours and 30 minutes.

-to

Deal with old files before the specified time. The format of the switch is the same as-tn.

-x excludes the specified file, and wildcards can be used in the file portion of the name and file mask. you

The switch'- x' can be specified several times.

If the mask contains wildcards, it is applied to the current directory and its subdirectories. Without wildcards, it doesn't.

Recursive, so if you want to exclude some "file names" from all folders, you need to specify two

Mask: the "file name" for the current directory and the "*\ filename" for the subdirectory. If

You know the exact path to a file, and you can use the "path\ file name" syntax to exclude only

This copy of the File name. If you use the-x path\ file name when unzipping a compressed file

Syntax, the "path" must be a path within a compressed file, not on the decompressed disk

The file path of the

Example:

1) rar a-r-x*.bak-x*.rar rawfiles

* .bak and * .rar will not be added to rawfiles

2) rar a-r-x *\ temp-x *\ temp\ * savec c:\ *

Compress C: all files except temporary directories and files in the Temp folder

3) rar x-x*.txt docs

Extract all files from docs.rar except * .txt

-y the answer to all questions is yes.

-? Displays help for commands and switches. It is the same as when there are no arguments or when illegal command line options are entered.

-- stop switch scanning

This switch tells RAR that there are no more switches on the command line. If you compress a file or file name

It starts with the-symbol and can be used. There is no'--'switch, such a name will be used as a switch

Treat.

Return value

~

RAR returns 0 after a successful operation. A non-zero return code means that the operation was canceled due to some error:

255 user interrupt user interrupt operation

9 creation error creating file error

8 memory error there is not enough memory to operate

7 user error command line option error

6 Open error opening file error

5 write error write to disk error

4 locked compressed file attempted to modify the compressed file previously locked with the'k 'command

3 CRC error A CRC error occurred while decompressing

2 fatal error A fatal error occurred

1 warning there is no fatal error

0 successful operation

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report