menu

开发进行时...

crazy coder

Avatar

rar的用法


Usage: rar <command> -<switch 1> -<switch N> <archive> <files...> <@listfiles...> <path_to_extract\>

<Commands>
a Add files to archive
c Add archive comment
cf Add files comment
ch Change archive parameters
cw Write archive comment to file
d Delete files from archive
e Extract files to current directory
f Freshen files in archive
i[par]=<str> Find string in archives
k Lock archive
l[t,b] List archive [technical, bare]
m[f] Move to archive [files only]
p Print file to stdout
r Repair archive
rc Reconstruct missing volumes
rn Rename archived files
rr[N] Add data recovery record
rv[N] Create recovery volumes
s[name|-] Convert archive to or from SFX
t Test archive files
u Update files in archive
v[t,b] Verbosely list archive [technical,bare]
x Extract files with full path

<Switches>
- Stop switches scanning
ad Append archive name to destination path
ag[format] Generate archive name using the current date
ap<path> Set path inside archive
as Synchronize archive contents
av Put authenticity verification (registered versions only)
av- Disable authenticity verification check
c- Disable comments show
cfg- Disable read configuration
cl Convert names to lower case
cu Convert names to upper case
df Delete files after archiving
dh Open shared files
ds Disable name sort for solid archive
e[+]<attr> Set file exclude and include attributes
ed Do not add empty directories
en Do not put 'end of archive' block
ep Exclude paths from names
ep1 Exclude base directory from names
ep3 Expand paths to full including the drive letter
f Freshen files
hp[password] Encrypt both file data and headers
id[c,d,p,q] Disable messages
ierr Send all messages to stderr
ilog[name] Log errors to file (registered versions only)
inul Disable all messages
isnd Enable sound
k Lock archive
kb Keep broken extracted files
m<0..5> Set compression level (0-store...3-default...5-maximal)
mc<par> Set advanced compression parameters
md<size> Dictionary size in KB (64,128,256,512,1024,2048,4096 or A-G)
ms[ext;ext] Specify file types to store
n<file> Include only specified file
n@ Read file names to include from stdin
n@<list> Include files in specified list file
o+ Overwrite existing files
o- Do not overwrite existing files
ol Save symbolic links as the link instead of the file
or Rename files automatically
ow Save or restore file owner and group
p[password] Set password
p- Do not query password
r Recurse subdirectories
r0 Recurse subdirectories for wildcard names only
rr[N] Add data recovery record
rv[N] Create recovery volumes
s[<N>,v[-],e] Create solid archive
s- Disable solid archiving
sc<chr><obj> Specify the character set
sfx[name] Create SFX archive
si[name] Read data from standard input (stdin)
sl<size> Process files with size less than specified
sm<size> Process files with size more than specified
t Test files after archiving
ta<date> Process files modified after <date> in YYYYMMDDHHMMSS format
tb<date> Process files modified before <date> in YYYYMMDDHHMMSS format
tk Keep original archive time
tl Set archive time to latest file
tn<time> Process files newer than <time>
to<time> Process files older than <time>
ts<m,c,a>[N] Save or restore file time (modification, creation, access)
u Update files
v Create volumes with size autodetection or list all volumes
v<size>[k,b] Create volumes with size=<size>*1000 [*1024, *1]
ver[n] File version control
vn Use the old style volume naming scheme
vp Pause before each volume
w<path> Assign work directory
x<file> Exclude specified file
x@ Read file names to exclude from stdin
x@<list> Exclude files in specified list file
y Assume Yes on all queries
z[file] Read archive comment from file

用法: rar <命令> -<选项1> ….-<选项N> <操作文档> <文件…> <@文件列表…> <解压路径>

通常rar命令由一个主命令加若干选项(可选)构成,操作文档为操作施加的.rar文件对象,
文件或文件列表为对操作文档实现修饰的具体文件或目录(可选)。

rar常用命令主要有
a 添加文件到操作文档
eg. rar a test.rar file1.txt 若test.rar文件不存在,则打包file1.txt文件成test.rar
rar a test.rar file2.txt 若test.rar文件已经存在,则添加file2.txt文件到test.rar中(这样
test.rar中就有两个文件了)
注,如果操作文档中已有某文件的一份拷贝,则a命令更新该文件
另,对目录也可以进行操作
eg. rar a test.rar dir1

c 对操作文档添加说明注释
eg. rar c test.rar
(会出现Reading comment from stdin字样,然后输入一行或多行注释,以ctrl+d结束)

cf 添加文件注释,类似上面的c,不过这个是对压缩文档中每个文件进行注释

cw 将文档注释写入文件
eg. rar cw test.rar comment.txt

d 从文档中删除文件
eg. rar d test.rar file1.txt

e 将文件解压到当前目录
eg. rar e test.rar
注,用e解压的话,不仅原来的file1.txt和file2.txt被解压到当前目录,就连dir1里面的所有文件
也被解压到当前目录下,不能保持压缩前的目录结构,如果想保持压缩前的目录结构,用x解压

k 锁定文档
eg. rar k test.rar 锁定文档后,该文档就无法进行任何更新操作了

r 修复文档
eg. rar r test.rar
当rar文件有问题时,可以尝试用该命令进行修复(鬼知道有多少用)

s 转换文档成自解压文档
eg. rar s test.rar
会生成一个test.sfx的可执行文档,运行它的效果就相当于rar x test.rar,
适合于向没有rar的用户传输文件

t 检测文档
eg. rar t test.rar
检测test.rar的完整性,一般压缩完大型文件准备传输前最好用这个命令来确保文件的正确性

x 带路径解压文档中内容到当前目录
eg. rar x test.rar
这样解压的话,dir1就会保持原来的目录结构

以上就是rar的常用命令,一个rar操作只能有一个命令,而选项却可以有多个。

rar选项有很多,在此无法一一说明,只示范经常使用的几个

cl 将文件名转换为小写
cu 将文件名转换为大写
eg. rar a -cl test.rar FILe.txt
FILe.txt在添加进test.rar之后,变为file.txt

df 文档操作后删除源文件
eg. rar a -df test.rar file1.txt file2.txt dir1
将file1.txt,file2.txt,dir1压缩到test.rar中之后,删除源文件

ed 不添加空目录
eg. rar a -ed test.rar dir1
添加dir1到test.rar中时,不对空目录进行操作
rar e -ed test.rar
解压test.rar时,不生成空目录

k 锁定文件
eg. rar a -k test.rar file1.txt
等价于rar a test.rar file1.txt
rar k test.rar

m<0..5> 设定压缩比等级(0-存储,3-默认,5-最大)
eg. rar a -m0 test.rar dir1 dir2
将dir1,dir2打包存储到test.rar,不进行实质上的压缩(速度奇快,适合于对无甚可压的文件进行操作
比如avi,jpg等)
rar a -m5 test.rar *.txt *.bmp
将当前目录下的txt文件和bmp文件打包压缩到test.rar中,使用最大压缩比(最慢)

ms[ext;ext] 特定文件采用非压缩方式
eg. rar a -m5 -ms avi;jpg;jpeg test.rar /home
将home目录下所有目录和文件归档到test.rar,采用最大压缩,但avi,jpg,jpeg文件不进行压缩
(只是打包进test.rar,因为这些文件即使用最大压缩也压不了多少,不如直接打包节省时间)

o+ 覆盖已有文件
o- 不覆盖已有文件
eg. rar x -o- test.rar
解压test.rar文件,但是如果碰到以存在的文件则不覆盖

ol 将符号链接以链接文件保存,而不是普通文件
ow 保存或者恢复文件所有者的信息(username,group)
这两个是*nix系统特有的命令,很容易理解吧

p[password] 设定密码
eg. rar a test.rar *.txt -p prettygirl
压缩文件设定密码为prettygirl,解压时无密码无法进行操作
如果觉得明码密码太过暴露,可以使用
rar a test.rar *.txt -p
则rar程序会询问你要使用什么密码,不回显

s- 不使用固实压缩
注,固实压缩就是压缩后文档内容不可变更的压缩方式,这和lock不一样。因为使用普通压缩
要照顾以后的插入删除个别文件的需要,就要留下很多操作余地。而固实压缩则不可以对
其内容进行任何更新,所以压缩比是最大的。

sfx[name] 创建自解压文件,这和先用a进行压缩,再用s转换效果是一样的。

t 压缩完毕后进行完整性检验
eg. rar a test.rar /home -t
压缩完毕后进行检验,如果有问题则报错。

ta<date> 仅对data日期后文件进行操作
tb<date> 仅对data日期前文件进行操作
注,date的格式为 YYYYMMDDHHMMSS 这样。

v<size>[k,b] 分卷压缩,每卷大小由后面的size指定
eg. rar a -v15000k -m0 test xvid-fn.avi
对xvid-fn.avi进行打包存储,每卷大小15000k(这种格式在网上发布dvdrip时很流行)
生成的文件名为test.part1.rar,test.part2.rar….(rar 3.20版)

x<file> 排除特定的文件
eg. rar x test.rar -x *.txt
解压test.rar中除*.txt以外的文档
x@<list> 同上,不过这次所有排除的文件放在list文件列表中

y 所有操作均回答yes
例如有时解压时每碰到相同文件就问是否覆盖(Y/N),加上-y就可以默认选择Yes,不再询问

评论已关闭