Using batch processing combined with WinRAR to easily compress files _dos/bat

Source: Internet
Author: User
Tags rar switches

It's a good idea to compress a winrar before backing up your data, which has at least the following advantages:

1. Save space. This depends on the nature of the source file, in general, the text-type Office document compression ratio is higher, and multimedia file compression effect is often not obvious.

2. Speed up replication. Backup files often need to be copied to n different locations/storage media, even if the volume of compressed file size changes, it is best to use the "storage Mode" compression, because in the same size, large chunks of a single file than a lot of files copied faster.

3. Confidentiality. You can use a compressed password to encrypt a file.

But every time right click on the file/folder, and then set the password, it is very troublesome, fortunately WinRAR support command-line mode, we can make a batch file to help us back up.

The WinRAR command line format is as follows:

The compressed file path and name source file path and name generated by the "E:\Program Files\winrar\winrar.exe" a switch

Description

"E:\Program Files\winrar\winrar.exe" is the location of WinRAR, if the path on your computer in other folders, please make the appropriate changes.

A: This is the command, A is the "add" command, which means adding a file to a compressed file. Whatever it is, if you want to compress it, take a with you.

Switch: Immediately following the command is a switch, switches can be added to many, according to their own hobbies casually. First look at the two simple, need to put directly behind the command can:

-SFX Self-extracting
-IBCK Background Run

Suggestions plus-ibck, let winrar hide in the background to slowly compress, not in front of our eyes dangling, annoying. This has no effect on the quality of compression, it only affects our mood.

Look at two more complex, saying they are complicated simply because the following can be followed by parameters:

-M storage mode: 0 storage, 1 fastest, 2 fast, 3 standard, 4 better, 5 optimal
-P Add Password:-p123, password is 123

-M: This switch is used to control the storage mode, which is the compression mode. If you do not add this switch, the default is the standard compression method. Storage mode has six kinds, from 0 to 5, compression rate is increasing, compression speed is more and more slow, you can according to the nature of compressed files to choose. Such as: File compression rate is not high, just 99%, so large can choose 0 storage mode to save time. If you want to choose 4 (better storage mode), then the switch is:-M4, other analogy

-P: This can add a password to the compressed file, directly followed by the password can be, such as:-p123, the file's password is 123.

OK, let's take a look at an example and try to see if we can understand:

"E:\Program files\winrar\winrar.exe" A–ibck–m5–pmima f:\ target. rar e:\ Source

Note: In the WinRAR command format, the source file should be placed behind the target, which is awkward, but there is nothing we can do to keep an eye on it.

This example means that the "source" folder under E-disk is compressed in the optimal compression mode, the "target. rar" file is generated in the F disk, and the password is set to "Mima" and compressed in the background. If you want to generate a self-extracting compressed file, add the-SFX parameter.

But this does not really apply to the normal backup, because in the second compression, the first backup will be deleted, so we want to add the command to delete old files (the third line below):

Copy Code code as follows:

@echo off
Color A9
Del f:\ target. rar
"E:\Program files\winrar\winrar.exe" a–ibck–m5–p password set f:\ target. rar e:\ Source
Pause

Copy the above command to Notepad, set the command switch, and then replace the target and source with your own file, save as a "compressed. bat" File (name is random, but. bat does not change), double-click to run, you can complete the backup.

For more commands and switches on the WinRAR command line, you can go to the WinRAR help file to find

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.