anchor.diff:  exit /b
   
   ::%1 - JPG|PNG|GIF
  +:fincalc
  +set /a "STotalSize%~1+=!TotalSize%~1!/!step%~1!"
  +set /a "SImageSize%~1+=!ImageSize%~1!/!step%~1!"
  +set /a "change%~1=(!SImageSize%~1!-!STotalSize%~1!)" 2>nul
  +set /a "perc%~1=!change%~1!*100/!STotalSize%~1!" 2>nul
  +set /a "fract=!change%~1!*100%%!STotalSize%~1!*100/!STotalSize%~1!" 2>nul
  +set /a "perc%~1=!perc%~1!*100+%fract%" 2>nul
  +::call:division change%~1 1024 100
  +call:division perc%~1 100 100
  +exit /b
  +
  +::%1 - JPG|PNG|GIF
   ::%2 - Total Size
   ::%3 - Image Size
   :calcstep
  -call set "total=%%TotalSize%1%%"
  -call set "img=%%ImageSize%1%%"
  -set "steping=0"
  -if %total% geq 1000000 set /a "steping+=1"
  -if %img% geq 1000000 set /a "steping+=1"
  -if %steping% gtr 0 (
  -	call set /a "TotalSize%1=%%TotalSize%1%%/1024"
  -	call set /a "ImageSize%1=%%ImageSize%1%%/1024"
  -	call set /a "step%1+=1"
  -)
  -set "total=%2"
  -set "img=%3"
  -call set "steping=%%step%1%%"
  -for /l %%f in (1,1,%steping%) do set /a "total/=1024" & set /a "img/=1024"
  -call set /a "TotalSize%1+=%total%"
  -call set /a "ImageSize%1+=%img%"
  +set /a "TotalSize%~1+=%~2"
  +set /a "ImageSize%~1+=%~2"
  +if !TotalSize%~1! lss %BYTECONV% if !ImageSize%~1! lss %BYTECONV% exit /b
  +set /a "STotalSize%~1+=!TotalSize%~1!/!step%~1!"
  +set /a "SImageSize%~1+=!ImageSize%~1!/!step%~1!"
  +set "TotalSize%~1=0"
  +set "ImageSize%~1=0"
  +if !STotalSize%~1! lss %BYTECONV% if !SImageSize%~1! lss %BYTECONV% exit /b
  +set /a "step%~1*=10"
  +set /a "STotalSize%~1/=10"
  +set /a "SImageSize%~1/=10"
   exit /b
   
   :totalmsg
  -call set /a "tt=%%TotalNum%1%%+%%TotalNumErr%1%%"
  -if "%2" equ "0" (
  +set /a "tt=!TotalNum%~1!+!TotalNumErr%~1!"
  +if "%tt%" equ "0" exit /b
  +if "%~2" equ "0" (
   	set "opt=0"
   	set "tterr=%tt%"
   	set "nopt=0"
   ) else (
  -	call set "nopt=%%TotalNumNOpt%1%%"
  -	call set /a "opt=%%TotalNum%1%%-!nopt!"
  -	call set "tterr=%%TotalNumErr%1%%"
  -)
  -if "%tt%" neq "0" (
  -	call:echostd " Total Number of %1:	%tt%"
  -	call:echostd " Optimized %1:		%opt%"
  -	if "%nopt%" neq "0" call:echostd " Not optimized %1:	%nopt%"
  -	if "%tterr%" neq "0" call:echostd " Skipped %1:		%tterr%"
  -	set "steping=0"
  -	call set "stepcur=%%step%1%%"
  -	for %%a in (byte KB MB GB TB) do (
  -		if !steping! equ !stepcur! call:echostd " Total %1:  		%%change%1%% %%a, %%perc%1%%%%%%"
  -		set /a "steping+=1"
  -	)
  -	call:echostd
  -)
  +	set "nopt=!TotalNumNOpt%~1!"
  +	set /a "opt=!TotalNum%~1!-!nopt!"
  +	set "tterr=!TotalNumErr%~1!"
  +)
  +echo. Total Number of %1:	%tt%
  +echo. Optimized %1:		%opt%
  +if "%nopt%" neq "0" echo. Not optimized %1:	%nopt%
  +if "%tterr%" neq "0" echo. Skipped %1:		%tterr%
  +set "stepcur=!step%~1!"
  +set "stepm=1"
  +for %%a in (KB KB KB MB MB MB GB GB GB TB TB TB) do (
  +	set /a "stepcur/=10"
  +	set /a "stepm=stepm*10%%1000"
  +	if !stepm! equ 0 set "stepm=1"
  +	if !stepcur! equ 1 (
  +		call:division change%~1 1 !stepm!
  +		echo. Total %1:  		!change%~1! %%a, !perc%~1!%%
  +))
  +echo.
   exit /b
   
   :listerrfiles
  
positive.code: 	set "TotalNum%%a=0"
  	set "TotalNumErr%%a=0"
  	set "TotalSize%%a=0"
  	set "ImageSize%%a=0"
  	set "change%%a=0"
  	set "perc%%a=0"
  )
  set "png="
  set "jpeg="
  
negative.code: call:waitrandom 500
  goto:createthread
  
  ::%1 - png | jpg | gif
  ::%2 - thread number
  :typelog
  if %thread% equ 1 exit /b
  if not defined typenum%1%2 set "typenum%1%2=1"
  call:typelogfile "%logfile%%1.%2" "typenum%1%2" %1
  ::call:typelogfile "%logfile%%1.%2" "typenum%1%2" %%typenum%1%2%% %1
  exit /b
  
  ::%1 - log file name (%logfile%)
  ::%2 - variable name - counter displayed files
  ::%3 - png | jpg | gif
  :typelogfile
  if not exist "%~1" exit /b
  set "tmpnum=!%~2!"
  for /f "usebackq skip=%tmpnum% tokens=1-5 delims=;" %%b in ("%~1") do (
  	if /i "%%d" equ "error" (
  		call:printfileerr "%%~b" "%%~c"
  	) else (
  		call:printfileinfo "%%~b" %%c %%d %%e %%f %3
  	)
  	set /a "%~2+=1"
  )
  exit /b
  
  ::%1 - file name
  ::%2 - original size in byte
  ::%3 - optimize size in byte
  ::%4 - change (%2 - %3)
  ::%5 - percent change (%4*100/%2)
  ::%6 - png | jpg | gif
  :printfileinfo
  if "%~4" equ "0" (
  	>>"%filelisterr1%" echo.%~f1
  	exit /b
  )
  setlocal  
  set "fn="
  call:cropfilename fn %1 %TFN%
  set "origsize=%2"
  call:division origsize 1024 100
  set "origsize=          !origsize!"
  