Using batch processing to copy and compress files

Posted on

Implementation code of copying and compressing files in batch processing

Copy codeThe code is as follows:
@echo on
REM assign source path to sp
set sp=D:/JavaWorkSpace/huayu_bbs
Under rem, get the current date and call the copy process
for /f “tokens=2 delims==” %%a in (‘wmic os get localdatetime /value^|findstr /i “LocalDateTime”‘) do (call :doit %%a)
pause
exit

:doit
set dt=%1
REM gets the original folder name and date of the source path, and copies (including subfolders)
xcopy /i /e “%sp%” “f:/fanxin/%sp:~3%-%dt:~0,4%-%dt:~4,2%-%dt:~6,2%”  

==========The above code means: copy all files under D: / javaworkspace / Huayu? BBS to the specified directory F: / fanxin, and then add the date after the folder
cd C:/Program Files/WinRAR  rar.exe  a -r -s -ep1 -m1  c:/finl/data.rar   C:/fanxin/
==========The above line of code means: compress all files under C: / fanxin / into a compressed package named data.rar and store it in the directory of C: / Finl /
@echo off

Batch copy files to multiple rar packages copy several files (jpg HTM reg TXT ICO) in the same directory to
All rar format compressed packages under the same drive letter

How to achieve it? Wait online ~ thank you

Copy codeThe code is as follows:
@echo off
set path=c:program fileswinrar;%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
)

Above D: change to the partition you want to operate, D: 1.txt D: 2.txt D: 3.txt change to the file you want to add, and save it as a bat file

Leave a Reply

Your email address will not be published.