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 realize the bat of migrating picture directory

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article is to share with you about how to implement the bat of migrating image directories. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The code is as follows:

@ echo off

Setlocal enabledelayedexpansion

:: enable variable delay, add custom variable name

Set sourpic=e:\ pic

:: define the picture source

Set despic=e:\ img

:: define the image storage address

Set pictype=*.jpg

:: define picture type

Set log=e:\ log.txt

:: define Log information, which is regenerated every time

Logging at the beginning of rem processing

Echo picture taken from:% sourpic% >% log%

Echo upload directory:% despic% > >% log%

Echo picture type:% pictype% > >% log%

Echo start time:% date%%time% > >% log%

:: after traversing the folder, traverse the corresponding folder one by one, copy pictures, log records, and delete pictures at the same time

For / d% I in (% sourpic%\ *) do (

:: traverses the root folder to get the subfolder name

Set folder=% ~ ni

Echo, yes! folder! Folder for operation

Echo # right! folder! Folder to operate:% date%%time% > >% log%

Rem begins to judge the directory of the server

Call: serverfolder% despic%! folder!% log%

Rem starts traversing the picture files in this folder

Call: copyfile% ~ fi! folder!

)

Echo date%%time%-- operation complete > > log%

Pause

Exit

Rem manages the directory of the target server

: serverfolder

If exist 1 2 (

Directory exists on the echo server side:% 1\% 2

) else (

Echo starts creating directories:% 1\% 2

Md 1 2

If% ERRORLEVEL% = = 0

Echo server side created 1 2 successfully! > > 3

) else (

Failed to create 1 2 on echo server side! > > 3

)

)

Goto:eof

Rem handles files in subfolders

: copyfile

For / r 1 I in (pictype%) do (

Echo starts copying:% I

Echo date%%time%--%%i > > log%

Copy% I% despic%\% 2\% ~ ni%%~xi / y

If% ERRORLEVEL% = = 0

Echo copy succeeded > > log%

Rem starts to delete

Del% I / Q

If% ERRORLEVEL% = = 0

Echo deleted successfully > > log%

) else (

Echo deletion failed > > log%

)

) else (

Echo copy failed > > log%

)

)

Goto:eof

Thank you for reading! This is the end of the article on "how to migrate the bat of the picture directory". 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, you can 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