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

Learn to write a batch file that can copy and extract files to a specified folder

2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

There are several folders and several compressed files in the scene 1:afoldersource, so now copy all the files in afoldersource to afolderdist.

Afoldersource:

Script:

@ ECHO OFF

# # turning off Command Echo

Echo copy file

# # display a sentence

SET sourcepath=E:\ afoldersource

# # defining Source address

SET destpath=E:\ afolderdist

# # define destination address

Rmdir% destpath%\ folder / s / Q

# # deleting a folder in the destination address

/ S means that all subdirectories and files under the specified directory will be deleted in addition to the directory itself. Used to delete a directory tree

/ Q indicates quiet mode. No confirmation is required when deleting the directory tree with / S.

Rmdir% destpath%\ lib / s / Q

# # deleting a folder in the destination address

Rmdir% destpath%\ test.war / s / Q

# # deleting files in the destination address

Robocopy sourcepath% destpath% / s / xo / ns/nc / nfl / ndl

# # copy the content of the source address to the destination address

/ S copy subdirectories, but not empty subdirectories

/ XO excludes older files

/ NS No size-File size is not recorded

/ NFL No File list-File names are not recorded.

/ NDL no directory list-directory names are not recorded.

Results:

There are several folders and several compressed files in the scene 2:afoldersource. Now copy all the files in afoldersource into afolderdist and extract the compressed files.

I need to install the decompression software first. I installed 7-Zip under C:\ Program Files\ 7-Zip\ 7z.exe.

Script:

@ ECHO OFF

Echo copy jy to jboss

SET sourcepath=E:\ afoldersource

SET destpath=E:\ afolderdist

Rmdir% destpath%\ folder / s / Q

Rmdir% destpath%\ lib / s / Q

Rmdir% destpath%\ test.war / s / Q

Robocopy% sourcepath%% destpath% / xf * .war/s / xo / ns / nc / nfl / ndl

# # do not copy compressed files

# # [/ XF file]... Exclude files that match a given name / path / wildcard]

"C:\ Program Files\ 7-Zip\ 7z.exe" Xmuro% destpath%\ test.war\-y% sourcepath%\ test.war > extract.log

# # decompress the file to the destination address

"C:\ Program Files\ 7-Zip\ 7z.exe" decompression software path

X: extract the file under the full path

-o: set the output directory

-y: all confirmation options default to Yes (that is, no confirmation prompt appears)

(extension:-aos: skip existing files)

Extract.log generates a log document named extract.log

Results:

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

Servers

Wechat

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

12
Report