To migrate the BAT code for a picture directory _dos/bat

Source: Internet
Author: User
Tags goto
Copy Code code as follows:

@echo off
Setlocal enabledelayedexpansion
:: Open variable delay, add custom variable name
Set Sourpic=e:\pic
:: Defining a picture source
Set despic=e:\img
:: Define picture Storage Address
Set Pictype=*.jpg
:: Defining picture types
Set Log=e:\log.txt
:: Defining log information, which is regenerated each time

REM processing starts with log records
echo Image taken from:%sourpic% >%log%
echo Upload directory:%despic% >>%log%
echo Picture type:%pictype%>>%log%
echo Start time:%date%%time%>>%log%

:: After the folder, traversing the corresponding folder, while copying pictures, log records, delete pictures

FOR/D%%i in (%sourpic%\*) do (
:: Traversing the root folder to get the subfolder name
Set folder=%%~ni
Echo operates on the!folder! folder
Echo # # #对!folder! folder to operate:%date%%time%>>%log%
REM begins to judge the directory of the server
Call:serverfolder%despic%!folder! %log%
REM begins traversing the picture file 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 (
There is a directory on the Echo server side:%1\%2
) Else (
Echo starts creating directory:%1\%2
MD%1\%2
If%errorlevel% ==0 (
echo Server-side creation%1\%2 successful! >>%3
) Else (
echo Server-side creation%1\%2 failed! >>%3
)
)
Goto:eof

REM Handles files for subfolders
: CopyFile
For/r%1%%i in (%pictype%) do (
echo Start copy:%%i
Echo%date%%time%--%%i>>%log%
Copy%%i%despic%\%2\%%~ni%%~xi/y
If%errorlevel% ==0 (
Echo Copy Successful >>%log%
REM begins to perform the deletion work
Del%%i/q
If%errorlevel% ==0 (
echo Delete Successful >>%log%
) Else (
Echo deletion failed >>%log%
)
) Else (
Echo Copy failed >>%log%
)
)
Goto:eof

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.