WinRAR的命令行模式用法介绍
因工作中要对数据打包,顺便研究了下WinRAR的命令行模式,自己写了些例子,基本用法如下:
测试压缩文件准备:文件夹test_data,内部包含子文件夹,分别存放了一些*.log和*.txt文件。
测试代码如下:
1 rem 压缩全部文件,按类型压缩,zip打包 2 WinRAR.exe a num_all.zip .\test_data 3 WinRAR.exe a num_txt.zip .\test_data\num*.txt 4 WinRAR.exe a num_log.zip .\test_data\num*.log 5 6 rem 压缩全部文件,按类型压缩,rar打包 7 WinRAR.exe a num_all.rar .\test_data 8 WinRAR.exe a num_txt.rar .\test_data\num*.txt 9 WinRAR.exe a num_log.rar .\test_data\num*.log 10 11 rem 默认压缩根目录,递归处理子文件夹使用 -r 12 WinRAR.exe a -r num_all_tg.zip .\test_data\*.* 13 WinRAR.exe a -r num_all_txt.zip .\test_data\*.txt 14 WinRAR.exe a -r num_all_log.rar .\test_data\*.log 15 16 17 rem 添加注释,注释从一个txt文件读取,txt文件名info.txt 18 WinRAR.exe c -zinfo.txt num_all.zip 19 WinRAR.exe c -zinfo.txt num_all.rar 20 21 rem 从压缩包中读取注释,写入到read.txt文件,默认ASCII,参数-scuc表示unicode 22 WinRAR.exe cw num_all.zip read1_ASCII.txt 23 WinRAR.exe cw num_all.rar read2_ASCII.txt 24 WinRAR.exe cw -scuc num_all.rar read_unicode.txt 25 26 rem 从压缩包中删除制定文件 27 WinRAR.exe d num_all_tg.zip *.log 28 29 rem 解压到当前目录下,不包含压缩包内的路径 30 WinRAR.exe e num_all_tg.zip 31 rem 解压到制定目录下,不包含压缩包内的路径 32 WinRAR.exe e num_all_tg.zip .\test_d2 33 rem 解压到当前目录下,只解压制定类型的文件 34 WinRAR.exe e num_all_tg.zip *.log 35 36 rem 给压缩包内的文件重命名 37 WinRAR.exe rn num_all_tg.zip num(1).txt num(1).bak num(2).txt num(2).bak 38 WinRAR.exe rn num_all.rar *.txt *.bak 39 40 rem 使用压缩包捏的绝对路径解压 41 WinRAR.exe x num_all_tg.zip 42 rem 使用压缩包捏的绝对路径解压,解压指定类型文件 43 WinRAR.exe x num_all_tg.zip *.log 44 rem 使用压缩包捏的绝对路径解压,解压指定类型文件,并解压到指定文件夹 45 WinRAR.exe x num_all_tg.zip *log .\new_data\
以上为winrar的基本压缩,,解压命令。
关于winrar 的开关选项,以后有空再研究整理。
备注:WinRAR.exe为安装完后,从安装目录将主程序winRAR.exe拷贝出来即可,该程序是独立可运行的。
以下为winRAR的命令帮助原文:
Alphabetic commands list
a add files to an archivec add an archive comment
ch change archive parameters
cv convert archives
cw write an archive comment to file
d delete files from an archive
e extract files from an archive, ignoring paths
f freshen files within an archive
i find string in archives
k lock an archive
m move files and folders to an archive
r repair a damaged archive
rc reconstruct missing volumes
rn rename archived files
rr[N] add data recovery record
rv[N] create recovery volumes
s[name] convert an archive to a self-extracting type
s- remove SFX module
t test archive files
u update files within an archive
x extract files from an archive with full paths
转载别人的翻译:
用法: rar <命令> -<开关 1> -<开关 N> <压缩文件> <文件...><@列表文件...> <解压路径">
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/67919.html