@echo off

cd/d "%~dp0"

set Src0=%~nx1

set Exp0=png
set Exp1=png

set Colors=256
set Opt0=-f -s1 --iebug
set Opt1=-quiet

set Dest0=%Src0%-%Colors%

set Error0=%Src0%
if not exist "%Error0%" goto Error



for %%f in (%Src0%\*.%Exp0%) do (
if not exist "%Dest0%" mkdir "%Dest0%"

echo  [ %%~nf.%Exp1% ] %Colors% colors...
_exe\pngquant.exe %Opt0% -o "%Dest0%\Tmp0-%%~nxf" %Colors% "%%f">nul
_exe\nconvert.exe %Opt1% -o "%Dest0%\%%~nf.%Exp1%" "%Dest0%\Tmp0-%%~nxf">nul

if exist "%Dest0%\Tmp0-%%~nxf" del /q "%Dest0%\Tmp0-%%~nxf">nul)


if exist "%Dest0%" if not exist "%Dest0%\*.*" rd /q "%Dest0%">nul
if not exist "%Dest0%\*.%Exp1%" pause



goto End
:Error
echo.
echo  [%Error0%] Not Found !
echo.
pause

:End
rem pause
