移転画像ディレクトリのbatコード


 
@echo off
setlocal enabledelayedexpansion
:: ,
set sourpic=e:\pic
::
set despic=e:\img
::
set pictype=*.jpg
::
set log=e:\log.txt
:: Log ,

rem
echo :%sourpic% >%log%
echo :%despic% >>%log%
echo :%pictype%>>%log%
echo :%date%%time%>>%log%

:: , , 、 、

for /d %%i in (%sourpic%\*) do (
:: root ,
set folder= %%~ni
echo !folder!
echo ### !folder! :%date%%time%>>%log%
rem
Call :serverfolder %despic% !folder! %log%
rem
Call :copyfile %%~fi !folder!
)
echo %date%%time%-- >>%log%
pause
exit

rem
:serverfolder
if exist %1\%2 (
echo :%1\%2
) else (
echo :%1\%2
md %1\%2
if %ERRORLEVEL% ==0 (
echo %1\%2 !>>%3
)else (
echo %1\%2 !>>%3
)
)
goto:eof

rem
:copyfile
for /r %1 %%i in (%pictype%) do (
echo :%%i
echo %date%%time%--%%i>>%log%
copy %%i %despic%\%2\%%~ni%%~xi /y
if %ERRORLEVEL% ==0 (
echo >>%log%
rem
del %%i /q
if %ERRORLEVEL% ==0 (
echo >>%log%
)else (
echo >>%log%
)
)else (
echo >>%log%
)
)
goto:eof