@echo off
setlocal ENABLEDELAYEDEXPANSION
set gs=C:\Program Files\gs\gs9.06\bin\gswin32c.exe
set count=0
set p=0
set ok=0
set rez=300
set quality=100
set format=jpeg
:::set rez=200
:::set quality=50
:::set format=jpeggray
echo "%~s1"
rem pause
if exist "%~s1" (
title Подождите идет подготовка...
echo Подождите идет подготовка...
mkdir "%~dpn1" > nul 2>&1
for /f "delims=" %%x in ('cmd /c ""%gs%" -dBATCH -dNOPAUSE -dNoCancel -sDEVICE=jpeg -sOutputFile="nul" -r5 "%~s1"" ^| find "Page"') do (
set count=%%~x
)
cls
set /a count=!count:* =!
for /l %%x in (1,1,!count!) do (
set n=0000%%~x
set n=!n:~-3!
"%gs%" -q -dBATCH -dNOPAUSE -dNoCancel -dJPEGQ=%quality% -sDEVICE=%format% -dFirstPage=%%~x -dLastPage=%%~x -sOutputFile="%~dpn1\%~n1 (Лист !n!).jpg" -r%rez% "%~s1" && set ok=1
<nul set /p xxx=.
set t=!t!.
set /a p="(100 * %%~x) / !count!"
title !p!%% !t!
)
)
if %ok%==1 explorer "%~dpn1"