Application of winrar compression/decompression in DOS

Source: Internet
Author: User
Tags rar

Use examples to illustrate the problem.

My WinRAR path:

C:/Program Files/winrar/winrar.exe

Usage: RAR < command >-< switch 1>-< switch n> < compressed file > < file ...> <@ list file ...> < decompression path/> < command >

[command line argument view]

Operation Steps:

1. C:/Program Files/winrar under the Rar.exe copy to the%systemroot%/system32, so you do not have to set RAR environment variables, and can directly again cmd command prompt using the RAR command.

(About environment variables: cmd command can not use what to do)

2. Create duxing.txt files and Dodo folders in C disk for a trial.

3. In operation, enter CMD to open the command prompt.

4. Then:

Compressed files:

C:/Documents and settings/administrator>cd/
C:/>rar a Duxing.rar duxing.txt
RAR 3.62 Copyright (C) 1993-2006 Alexander roshal 32 months 2006
Share version input RAR-? Get help
Evaluation version, please register
Creating compressed Files Duxing.rar
Adding Duxing.txt complete
Complete

Compressed folder:

C:/>rar a Dodo.rar Dodo
RAR 3.62 Copyright (C) 1993-2006 Alexander roshal 32 months 2006
Share version input RAR-? Get help
Evaluation version, please register
Creating compressed Files Dodo.rar
Adding Dodo complete
Complete

WinRAR how to bulk compress a folder

1. Drag and drop file compression:
Create a bat with the following contents:

RAR a%1.rar%1

You can then compress the file or folder that you want to compress in turn by dragging it onto the bat icon.

You can save a little bit of things.

------update--2008.11.18--the world.

In the dos bar post for advice return ~ ~

@echo off
REM--Sets the specified path to D:/test, and the user can customize
Set "Pt=d:/test"

REM-Gets the names of all files and folders under the specified path
for/f%%i in (' dir/b d:/test ') do (

REM--This is the command argument shown here
RAR a d:/test/%%~ni.rar d:/test/%%i
)
echo Complete.
Ping-n 3 127.0.0.1>nul

Description of the batch above:

1. REM is followed by annotations;
2. Set "Pt=d:/test" setting is the path, test every file and folder will be compressed into a single RAR package;
3. for/f%%i in (' dir/s/b d:/test ') is what I found in the DOS bar, which means that the name of the file and folder under the D:/test path is taken as the next parameter
4. rar a d:/test/%%~ni. rar%%i The d:/test/set is the compressed package store path%%~ni indicates the name of the compressed package (without the extension of the original file, such as the original file is Duxing.txt compressed Duxing.rar, this situation requires a note Meaning, if there is a Duxing.java in the same directory, will also be added to the Duxing.rar package; to include the original file name, change this section to%%i, and after compression, the name is Duxing.txt.rar).
5. The last line of Ping-n 3 127.0.0.1>nul is 3 seconds after the end of the program, close the window
6. Tips: The creation of this bat file, if placed in the path of the compression source, itself will be compressed, so pay attention to, do not need to delete it. If the bat file is placed outside the path to compress the source, you do not have to consider this issue.

7. A method that does not consider the environment variable, that is, the command explicitly indicates the Rar.exe path:
(My RAR.exe path: C:/Program files/winrar/rar.exe)
@echo off
REM--Sets the specified path to D:/test
, and the user can customize
Set "Pt=d:/test"

REM-Gets the names of all files and folders under the specified path
for/f%%i in (' dir/b d:/test ') do (

REM--This is the command argument shown here
"C:/Program Files/winrar/rar.exe" a d:/test/%%~ni.rar d:/test/%%i
)
echo Complete.
Ping-n 3 127.0.0.1>nul


8. Defect : Can only handle the contents of a folder; The object name you want to compress cannot contain spaces.

Explained the principle, you can also modify this code, the proposal in the formal use, please create a new folder, test, consider the various circumstances will have unexpected effects.

Finally wish you to run successfully, thanks to the DOS bar of the unknown mentor ~ ~

REM--Command update 18:42 2008-11-25 support files and file names contain spaces
REM--Http://hi.baidu.com/duxing the world

@echo off
REM--Sets the specified path to D:/test, and the user can customize
Set "Pt=d:/test"

REM-Gets the names of all files and folders under the specified path
for/f "tokens=*"%%i in (' dir/b%pt% ') do (

REM--This is the command argument shown here
RAR a "%pt%/%%i" "%pt%/%%i"
)
echo Complete.
Pause

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Decompression in the file command line is also almost operation, the first WinRAR installation directory under the Unrar.exe copy to C:/windows/system32 under

Usage: Unrar < command >-< switch 1>-< switch n> < compressed file > < file ...>
<@ List File ...> < decompression path/>

< notes >
E Extract compressed files to current directory
L[T,B] List compressed files [technical information, concise]
P print files to standard output devices
T Test compressed file
V[T,B] Detailed list of compressed files [technical information, concise]
x extract files with absolute path

< switch >
-Stop Scanning
Clear Archive Properties After AC compression or decompression
Ad Add compressed file name to target path
Ai ignores file properties
ap< path > Add path to Compressed file
av-Disable user authentication
C-Disable Comment display
cfg-Disable Read configuration
CL name conversion to lowercase
CU name converted to uppercase
DH Open Shared File
EP excludes path from name
The EP3 extension path is the full path containing the letter
F Refresh File
ID[C,D,P,Q] Prohibit information display
Ierr send all messages to standard error devices
Inul Disable all messages
Ioff turn off PC Power after completing one operation
KB Keep corrupted uncompressed files
n< files > include only specified files
n@ read the file names to include from the standard input device
n@< list > Include files in specified list files
o[+|-] Set Overlay mode
OC Set NTFS Compression properties
or automatically renames a file
ow save or restore file ownership and group
[Password] Set password
P-Don't ask for password
R contains subdirectories
Ri<p>[:<s>] Set Priority (0-default, 1-Min.). 15-Max) and Hibernate time (MS)
sl< size > Handling files smaller than the specified size
sm< size > Handling files larger than the specified size
ta< Date > Add date < date > modified file, date format YYYYMMDDHHMMSS
tb< Date > Add Date < date > Previous modified file, date format YYYYMMDDHHMMSS
tn< time > Add < time > later files
to< time > Add < time > previous files
Ts<m,c,a>[n] Save or restore file time (modify, create, access)
U Update files
V List all volumes
Ver[n] File version control
VP Pause before each volume
x< file > exclude specified files
x@ read the file name to exclude from the standard input device
x@< list > Exclude files in a specified list file
Y Suppose the answer to all inquiries is

Example: (Extract a file to the current directory) D:/>unrar x 123.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.