Цитата: т.е. когда проверяется png и их нет, то мы переходим к jpeg и вот если нет jpeg, то выводим сообщение что файлов нет и батник закрывается
т.е. просто молчаливое закрытие, как сейчас - тебя чем-то не устраивает?
[more=держи]
Код: Rem 24/03/2010
@echo off
1>nul 2>nul dir /b /s /a-d Images\*.png || goto:jpeg
:loop1
echo [1] PNG Interlace - Noninterlaced
echo [2] PNG Interlace - Adam7
set /p png="Choose a task by number: "
if not defined png goto:eof
if %png%==1 goto:Noninterlaced
if %png%==2 goto:Adam7
goto:loop1
:Noninterlaced
echo Noninterlaced
Rem Optimization PNG (Interlace - Noninterlaced)
for /f "delims=" %%i in ('dir /b /s /a-d Images\*.png') do (
call :png "%%~fi"
"%~dp0Docs\pngcrush.exe" -rem alla -brute -reduce "%%~fi" "%%~dpni.tmp"
move /y "%%~dpni.tmp" "%%~fi"
"%~dp0Docs\advdef.exe" -z -4 "%%~fi"
"%~dp0Docs\deflopt.exe" "%%~fi"
"%~dp0Docs\optipng.exe" -zc1-9 -zm1-9 -zs0-3 -f0-5 "%%~fi"
"%~dp0Docs\advdef.exe" -z -4 "%%~fi"
"%~dp0Docs\deflopt.exe" "%%~fi"
"%~dp0Docs\pngout.exe" "%%~fi"
"%~dp0Docs\advdef.exe" -z -4 "%%~fi"
"%~dp0Docs\deflopt.exe" "%%~fi"
)
goto:jpeg
:png
for /f "delims==,IDAT tokens=5" %%i in ('"%~dp0Docs\optipng.exe" -i0 -zc1-9 -zm1-9 -zs0-3 -f0-5 -full -force %1') do set f=%%i
set f=%f:~1,1%
"%~dp0Docs\pngout.exe" /k0 /n2 /f%f% %1
goto:eof
:Adam7
echo Adam7
Rem Optimization PNG (Interlace - Adam7)
for /f "delims=" %%i in ('dir /b /s /a-d Images\*.png') do (
"%~dp0Docs\optipng.exe" -i1 "%%~fi"
"%~dp0Docs\pngcrush.exe" -rem alla -brute -reduce "%%~fi" "%%~dpni.tmp"
move /y "%%~dpni.tmp" "%%~fi"
"%~dp0Docs\advdef.exe" -z -4 "%%~fi"
"%~dp0Docs\deflopt.exe" "%%~fi"
"%~dp0Docs\optipng.exe" -zc1-9 -zm1-9 -zs0-3 -f0-5 "%%~fi"
"%~dp0Docs\advdef.exe" -z -4 "%%~fi"
"%~dp0Docs\deflopt.exe" "%%~fi"
)
:jpeg
1>nul 2>nul dir /b /s /a-d Images\*.jpg Images\*.jpeg && goto:loop2
if not defined png echo Not found: Images\*.png Images\*.jpg Images\*.jpeg
goto:eof
:loop2
echo [1] JPEG - Optimize
echo [2] JPEG - Progressive
echo [3] JPEG - Progressive vs. Optimize
set /p jpeg="Choose a task by number: "
if not defined jpeg goto:eof
if %jpeg%==1 goto:Optimize
if %jpeg%==2 goto:Progressive
if %jpeg%==3 goto:P_Optimize
goto:loop2
:Optimize
echo JPEG - Optimize
Rem Optimization JPEG (Optimize)
for /f "delims=" %%i in ('dir /b /s /a-d Images\*.jpg Images\*.jpeg') do (
"%~dp0Docs\jpegtran.exe" -copy all -optimize "%%~fi" "%%~fi"
"%~dp0Docs\jhead.exe" -dc -de -di -dx -du "%%~fi"
)
goto:eof
:Progressive
echo JPEG - Progressive
Rem Optimization JPEG (Progressive)
for /f "delims=" %%i in ('dir /b /s /a-d Images\*.jpg Images\*.jpeg') do (
"%~dp0Docs\jpegtran.exe" -copy all -progressive "%%~fi" "%%~fi"
"%~dp0Docs\jhead.exe" -dc -de -di -dx -du "%%~fi"
)
goto:eof
:P_Optimize
echo JPEG - Progressive vs. Optimize
Rem Optimization JPEG (Progressive vs. Optimize)
for /f "delims=" %%i in ('dir /b /s /a-d Images\*.jpg Images\*.jpeg') do (
"%~dp0Docs\jpegtran.exe" -copy all -progressive "%%~fi" "%%~dpni_pro.tmp"
"%~dp0Docs\jpegtran.exe" -copy all -optimize "%%~fi" "%%~dpni_opt.tmp"
call :compare "%%~dpni_pro.tmp" "%%~dpni_opt.tmp" "%%~fi" "%%~nxi"
"%~dp0Docs\jhead.exe" -dc -de -di -dx -du "%%~fi"
)
goto :eof
:compare
if %~z1 LSS %~z2 (
DEL /F /Q %2
DEL /F /Q %3
REN %1 %4
) else (
DEL /F /Q %1
DEL /F /Q %3
REN %2 %4
)
goto:eof