RAR Commands

 RAR. Win RAR 

WinRAR’s superspy CLI (Command Line Interface) version is named, simply, rar (actually rar.exe, but we’re going to call it just “rar” from now on). Best way to use it easily is to add “C:\Program Files\WinRAR” to your PATH environment variable, like you learned when we talked about “tar” and its friends. Once you’ve done that, type the command “rar” and press Enter in order to see a rather lengthy list of options and switches (flags) – we’ll be reviewing here the most important ones.

Unlike tar & co., rar’s main commands (create archive, extract and so on) are not treated like switches (flags) but are used “as-is” – a single letter immediately after the command invocation (e.g. “rar a ..” to create a new archive).

Basic commands in RAR

a – Add files to archive 
Used to create a new archive or add files to an existing one
Example: “rar a allmydocs.rar *.doc” creates a RAR archive that contains all the doc files in the current directory.

c – Add archive comment
Used to add a text comment to an existing archive
Example: “rar c allmydocs.rar” allows you to interactively enter some text, which will be added to the archive as a comment.
An interesting variant of this option is cw, which dumps the comment to a file of your choice. “rar cw allmydocs.rar doc-comments.txt” would read the comment inside your archive and write it to the txt file.

e – Extract files to current directory
Used to quickly extract files from within an existing archive. Optionally, it can get only certain files (specified on the command line)
Extract all files example: “rar e allmydocs.rar” would uncompress all the arhive contents in the current directory
Extract certain file example: “rar e allmydocs.rar must-read.doc” would get only the must-read.doc out of the archive and put it in the working directory.

f – Freshen files in archive
Update archive by refreshing files that were modified since they were added to the archive or last “freshened”.
Example: “rar f allmydocs.doc” would check all corresponding files against their copy inside the archive, and update the archive where differences are found.

l – List archive
Used to display a list of files and other details contained by the archive. There are 3 modes for this command, each with its distinct set of info columns.

Default mode (l)
Shows file name, real size (in bytes), packed size, compression ratio, date and time, attributes, the CRC (Cyclic Redundancy Check) hash, the compression method and version.
Example: “rar l allmydocs.rar”

Technical mode (lt)
Additionally displays the Host OS (operating system used to create the archive, whether or not the archive is solid, and if the format is “old” or not.
Example: “rar lt allmydocs.rar”

Bare mode (lb)
Displays only the file names
Example: “rar lb allmydocs.rar”

Slightly more advanced stuff

d – Delete files or folders from archive
Used to delete one or more files inside an existing archive
Example: “rar d allmydocs.rar mustdelete.doc” would delete a single doc file from the archive
Another example: “rar d allmydocs.rar old_docs” would delete the entire “old_docs” folder (that is, including the contents)

t – Test archive files
Used to test that an archive is not damaged. Works by performing a fake extraction of the archive contents (extracted data is not actually written to disk).
Example: “rar t allmydocs.rar”

x – Extract files with full path
Used to obtain some files out of an archive, or to uncompress an entire archive. The files are extracted with “full paths”, which means the directory structure is recreated to match the one at the time of compression.

Simple mode:
Extracts all files in a RAR arhive
Example: “rar x allmydocs.rar”

Advanced mode:
Lets you skip extraction of files you don’t need, either by typing their names on the command line or by providing a exclusion list file.
Example (1): “rar x –xuseless.doc allmydocs.rar” (skips useless.doc while uncompressing the archive)
Example (2): “rar x –x@ allmydocs.rar” (then type filenames you want to skip)
Example (3): “rar mailto:x%20-x@skip.txt allmydocs.rar” (all files specified in skip.txt will be skipped)

Even more advanced stuff (good to impress on the first date)

s – Convert to SFX / remove SFX module
The default form of this command adds a SFX module to the archive of your choice, transforming it into a self-extracting ”.exe” archive, perfect if you want to distribute the archive but suspect that some of the recipients do not have a compression program capable of handling RAR files. The default.sfx module is used or, optionally, one specified in the command line immediately after the s command.
Example: “rar s allmydocs.rar”.

The “evil twin” of this command is s-, which removes SFX modules.
It will not overwrite the self-extracting (.exe) archive, but will create a new one with the usual “.rar” extension.
Example: “rar s- allmydocs.exe” creates a new archive named “allmydocs.rar”

r – Repair archive
Attempts to repair a damaged archive using any available recovery records. If recovery records are not available, rar will only reconstruct the archive (i.e. the file list), in order to be able to recover undamaged files. If recovery records are in fact available, rar can be much more efficient and rebuild the entire archive.
The repaired archive is saved to rebuilt.original_name.rar (no recovery record) or fixed.original_name.rar (recovery record(s) found).
Example: “rar r allmydocs.rar”

The rc variant of this command is designed to work with multi-volume archives and can reconstruct missing volumes.
The rr variant can be used to add a recovery record to an existing archive; for example “rar rr allmydocs.rar”.
The rv variant does the same thing, but for multi-volume archives; the recovery records are external files with the “.rev” extension.

u – Update files in archive
Adds files that are not in the archive (using the initial file spec used when creating the archive) and freshens the ones that already are included (see the f command). If you created an archive with a command such as “rar a allmydocs.rar *.doc”, updating it will look for new .doc files and add them to allmydocs.rar, plus it will check what files inside the archive have been modified in the “real world” – the filesystem.
Example: “rar u allmydocs.rar”

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值