Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to copy and compress files by batch processing

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail how to use batch processing to achieve file replication and compression. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Batch copy and compress the implementation code of the file

The code is as follows:

@ echo on

Rem assigns the source path to sp

Set sp=D:/JavaWorkSpace/huayu_bbs

Get the current date under rem and call the copy process

For / f "tokens=2 delims=="% an 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 then copies it (including subfolders)

Xcopy / I / e "% sp%"f _ v _ max _ fan _ in _ ax% sp _ R _ 3% mi% DT _ R _ 0J 4% m% DT _ R _ 4% I% I% DT _ R _ 6% 2%

The above code means: copy all the files under D:/JavaWorkSpace/huayu_bbs to the specified directory f:/fanxin, and add a date to 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 that all files under C:/fanxin/ are compressed into a compressed package named data.rar and stored in the c:/finl/ directory.

@ echo off

Batch copy files into multiple RAR packages to copy several file (jpg htm reg txt ico) format files in the same directory to

In all RAR compressed packages under the same disk character

How to achieve it? Wait online. Thank you.

The code is 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

)

Replace the above d:\ with the partition you want to operate, d:\ 1.txt d:\ 2.txt d:\ 3.txt with the file you want to add, and save it as a bat file

On "how to use batch processing to achieve file replication and compression" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report