Implementation code for File replication and compression using batch processing _dos/bat

Source: Internet
Author: User
Tags rar

Batch copy and compress the implementation code of a file

Copy Code code as follows:

@echo on
REM assigns the source path to the SP
Set Sp=d:/javaworkspace/huayu_bbs
REM Gets the current date and calls the copy process
for/f "tokens=2 delims=="%%a in (' WMIC OS get localdatetime/value^|findstr/i ' LocalDateTime ') does (call:d oit%%a)
Pause
Exit

:d OIT
Set dt=%1
REM Gets the source path to the original folder name and date, and then copies (contains subfolders)
xcopy/i/e "%sp%" "f:/fanxin/%sp:~3%-%dt:~0,4%-%dt:~4,2%-%dt:~6,2%"

========== the above code means to copy all the files under D:/javaworkspace/huayu_bbs to the specified directory f:/fanxin, and then add a date to the back of the folder
CD C:/Program Files/winrar rar.exe a-r-s-ep1-m1 C:/finl/data.rar
========== This line of code means that all the files under c:/fanxin/are compressed into a compressed package known as Data.rar and stored in the c:/finl/directory.
@echo off

Batch copy files are copied to multiple RAR compressed packages to copy several files (jpg htm reg txt ico) files in the same directory to
All RAR format compression packages under the same letter

How to achieve it? Online wait ~ Thank you

Copy Code code as follows:

@echo off
Set Path=c:\program files\winrar\;%path%
FOR/R d:\%%i in (.) Do (
pushd%%i
For%%i in (*.rar) do rar a%%i d:\1.txt d:\2.txt d:\3.txt
)

The above d:\ for the partition you want to operate, D:\1.txt D:\2.txt D:\3.txt replaced by the file you want to add, save as a bat file

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.