Now I have a solution. Got the main code and just modified a bit for flexible usage on different paths etc. Tested and working. But I have no idea comparing to dbenhams code. Which is better etc???
Note that, simply adding %NUMBER_OF_PROCESSORS% variable makes this code flexible between computers also.
This file is managing the multiple instances.
Code: Select all
@ECHO OFF
SETLOCAL
SET epath=%~dp0
CD /D %epath%
SET /a instances=%NUMBER_OF_PROCESSORS%
:: make a tempfile
:maketemp
SET "tempfile=%temp%\%random%"
IF EXIST "%tempfile%*" (GOTO maketemp) ELSE (ECHO.>"%tempfile%a")
::
:loop
SET "nextfile=%~1"
IF NOT DEFINED nextfile (
ECHO all done
DEL "%tempfile%a*" >NUL 2>NUL
GOTO :eof
)
FOR /L %%a IN (1,1,%instances%) DO (
IF NOT EXIST "%tempfile%a%%a" (
>"%tempfile%a%%a" ECHO.
START "Instance %%a" oneconversion "%~1" "%tempfile%a%%a" %%a
SHIFT
GOTO loop
)
)
timeout /t 1 >NUL
GOTO loop
GOTO :EOF
This one (called oneconversion.bat) does the action
Code: Select all
@ECHO OFF
SETLOCAL
SET fpath=%~dp1
SET epath=%~dp0
CD /D %epath%
ECHO File Path [ %fpath% ]
ECHO Exe Path [ %epath%bin ]
ECHO Core Count [ %NUMBER_OF_PROCESSORS% ]
ECHO ____________________________________________________________
COPY /Y "%~f1" "%fpath%\%~nx1.bak" >NUL
bin\truepng.exe /f4 /g0 /a0 /l q=4 m=1 /i0 /md remove all /zc9 /zm9 /zs1 /quiet /y /out "%~f1" %1 >NUL
timeout 1 >NUL
bin\pngwolf.exe --in="%~f1" --out="%~f1" --exclude-singles --exclude-heuristic --max-stagnate-time=2 --max-evaluations=1 --7zip-mpass=2 >NUL
timeout 1
DEL "%fpath%\*.bak" /F/Q
DEL "%~2" >NUL 2>NUL
cls
exit
Note: The line "DEL "%fpath%\*.bak" /F/Q" is deleting the backups. Simply comment it to keep them. And the commands on softwares (truepng and pngwolf) are the exact that I defined after tests. Anyone intereted in PNG optimize can try.
All bests and thanks to anyone gave a hand to help.