rar和unrar的用法

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

压缩rar命令

  • a 添加文件到压缩文件
  • c 添加压缩文件注释
  • cf 添加文件注释
  • cw 写入压缩文件注释到文件
  • d 删除压缩文件中的文件
  • e 解压压缩文件到当前目录
  • f 刷新压缩文件中的文件
  • i[参数]=<串> 在压缩文件中查找字符串
  • k 锁定压缩文件
  • l[t,b] 列出压缩文件[技术信息,简洁]
  • m[f] 移动到压缩文件[仅对文件]
  • p 打印文件到标准输出设备
  • r 修复压缩文件
  • rc 重建丢失的卷
  • rn 重命名压缩文件
  • rr[N] 添加数据恢复记录
  • rv[N] 创建恢复卷
  • s[名字|-] 转换压缩文件为自解压格式或转换回压缩文件
  • t 测试压缩文件
  • u 更新压缩文件中的文件
  • v[t,b] 详细列出压缩文件[技术信息,简洁]
  • x 用绝对路径解压文件

压缩rar选项

  • - 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
  • dw Wipe files after archiving
  • 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[+|-] Set the overwrite mode
  • 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 in YYYYMMDDHHMMSS format
  • tb<date> Process files modified before in YYYYMMDDHHMMSS format
  • tk Keep original archive time
  • tl Set archive time to latest file
  • tn<time> Process files newer than
  • to<time> Process files older than
  • 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=*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

解压unrar命令

  • e 解压文件到当前目录
  • l[t,b] 列出压缩文档信息[technical, bare]
  • p 打印文件到标准输出
  • t 测试压缩我俄当
  • v[t,b] 列出压缩文档的详细信息[technical,bare]
  • x 解压文件到完整路径

解压unrar选项

  • - Stop switches scanning
  • ad Append archive name to destination path
  • ap<path> Set path inside archive
  • 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
  • dh Open shared files
  • ep Exclude paths from names
  • ep3 Expand paths to full including the drive letter
  • f Freshen files
  • id[c,d,p,q] Disable messages
  • ierr Send all messages to stderr
  • inul Disable all messages
  • kb Keep broken extracted files
  • n<file> Include only specified file
  • n@ Read file names to include from stdin
  • n@<list> Include files in specified list file
  • o[+|-] Set the overwrite mode
  • or Rename files automatically
  • ow Save or restore file owner and group
  • p[password] Set password
  • p- Do not query password
  • r Recurse subdirectories
  • sl<size> Process files with size less than specified
  • sm<size> Process files with size more than specified
  • ta<date> Process files modified after in YYYYMMDDHHMMSS format
  • tb<date> Process files modified before in YYYYMMDDHHMMSS format
  • tn<time> Process files newer than
  • to<time> Process files older than
  • ts<m,c,a>[N] Save or restore file time (modification, creation, access)
  • u Update files
  • v List all volumes
  • ver[n] File version control
  • vp Pause before each volume
  • 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

具体示例

  • rar a file file.ext
    如果file.rar不存在将创建file.rar文件;如果file.rar压缩包中已有file.ext,将更新压缩包中的file.ext;

  • rar a -r -v2000 -s -sfx -rr file
    从当前文件夹和子文件夹压缩全部文件成为 2000000 字节大小、固实的、分卷自解压文件 file.part1.exe,file.part2.rar,file.part3.rar 等,并在每一个分卷中添加恢复记录;将命令a换成命令m可将文件压缩后删除

  • rar x Fonts *.ttf
    会从压缩文件解压 *.ttf 字体文件到当前文件夹,但下面命令:
    rar x Fonts *.ttf NewFonts
    会从压缩文件解压 *.ttf 字体文件到文件夹 NewFont

  • rar a -pZaBaToAd -r secret games\*.*
    使用密码 ZaBaToAd 来将文件夹“games”的内容添加到压缩文件“secret”

  • rar a -r a.rar a/
    递归的将a/下所有东西压缩到a.rar

  • rar a test.rar file1.txt
    若test.rar文件不存在,则打包file1.txt文件成test.rar

  • `rar c test.rar
    对操作文档添加说明注释

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

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

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

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

  • rar r test.rar
    当rar文件有问题时,可以尝试用该命令进行修复

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

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

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

  • rar a -cl test.rar FILe.txt
    FILe.txt在添加进test.rar之后,变为file.txt

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

  • rar a -ed test.rar dir1
    添加dir1到test.rar中时,不对空目录进行操作

  • rar e -ed test.rar
    解压test.rar时,不生成空目录

  • rar a -m0 test.rar dir1 dir2
    将dir1,dir2打包存储到test.rar,不进行实质上的压缩(速度奇快,适合于对无甚可压的文件进行操作比如avi,jpg等)m<0..5> 设定压缩比等级(0-存储,3-默认,5-最大)

  • rar a -m5 test.rar *.txt *.bmp
    将当前目录下的txt文件和bmp文件打包压缩到test.rar中,使用最大压缩比(最慢)

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

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

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

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