@echo off SETLOCAL EnableDelayedExpansion set _exe=C:\prg\ghostscript\bin\gswin64c.exe set _outputdir=%temp% set _errmsg= set _firstpage=1 set _lastpage=1 set _sourcefile=%1 if not defined _sourcefile set _sourcefile=PDF-File :restart call :checksource %_sourcefile% if defined _errmsg goto errmsg call :checkpdf %_sourcefile% if defined _errmsg goto errmsg call :create_output if defined _errmsg goto errmsg set /p _firstpage=Erste Seite [%_firstpage%]: set /p _lastpage=Letzte Seite [%_lastpage%]: FOR /L %%n IN (%_firstpage%,1,%_lastpage%) DO ( call :create_output echo.creating !_outputfile! set _outputfile[%%n]=!_outputfile! REM echo."%_exe%" -q -dBATCH -dMaxBitmap=241304527 -dNOPAUSE -dSAFER -sDEVICE=jpeg -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r300 -dFirstPage=%%n -dLastPage=%%n -sOutputFile=!_outputfile! %_sourcefile% -c quit "%_exe%" -q -dBATCH -dMaxBitmap=241304527 -dNOPAUSE -dSAFER -sDEVICE=jpeg -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r300 -dFirstPage=%%n -dLastPage=%%n -sOutputFile=!_outputfile! %_sourcefile% -c quit && ( if exist !_outputfile! ( start "File %%n" !_outputfile! ) else ( set _errmsg=Output-File wurde nicht erzeugt ) ) || ( set _firstpage%,1,%_lastpage% ) ) if defined _errmsg goto errmsg set _answer=N set /p _answer=browse Files [Y/N]? if /I "%_answer:~0,1%"=="J" set _answer=Y rem if /I "%_answer:~0,1%"=="Y" explorer.exe /n, /e, "%_outputdir%" if /I "%_answer:~0,1%"=="Y" explorer.exe /select,!_outputfile! set _answer=N set /p _answer=delete temp Files [Y/N]? if /I "%_answer:~0,1%"=="J" set _answer=Y if /I "%_answer:~0,1%"=="Y" ( FOR /L %%n IN (%_firstpage%,1,%_lastpage%) DO ( echo.deleteing !_outputfile[%%n]! del !_outputfile[%%n]! ) pause ) set _answer=N set _sourcefile=PDF-File set /p _answer=Next PDF-File [Y/N]? if /I "%_answer:~0,1%"=="J" set _answer=Y if /I "%_answer:~0,1%"=="Y" goto :restart goto end ::functions :create_output call :Unique _timestamp set _outputfile=%temp%\pdf_!_timestamp!.jpg call :checkoutput %_outputfile% exit /b :checkpdf if /i "%~x1"==".pdf" exit /b set _errmsg=File ist kein .PDF exit /b :checksource set _sourcefile="%~1" :checksource2 if exist %_sourcefile% exit /b if not %_sourcefile%=="PDF-File" echo.Kann %_sourcefile% nicht finden goto ask4pdf :ask4pdf set /p _sourcefile=PDF-File: goto checksource2 :checkoutput set _outputfile="%~1" set _outputdir=%~dp1 if exist "%~dp1\." exit /b md "%_outputdir%" if exist "%~dp1\." exit /b set _errmsg=ERROR: kann Verzeichnis nicht erzeugen "%_outputdir%" exit /b :Unique ret -- returns a 16 digits unique string based on a date-time-stamp, YYYYMMDDhhmmsscc :: -- ret [out,opt] - unique string :$created 20060101 :$changed 20080219 :$categories StringOperation,DateAndTime ::modified by Mark Wolfgruber 20110414 : if less than 10 adding leading zero for %yy%, %mm% and %dd% ::modified for german enviroment by Mark Wolfgruber 20101129 :$source http://www.dostips.com SETLOCAL for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('"echo.|date"') do ( for /f "tokens=1-3 delims=/.- " %%A in ("%date:* =%") do ( set %%a=%%A&set %%b=%%B&set %%c=%%C)) if DEFINED jj set yy=%jj% if DEFINED tt set dd=%tt% set /a "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100" if %yy% LEQ 9 set mm=0%yy% if %mm% LEQ 9 set mm=0%mm% if %dd% LEQ 9 set dd=0%dd% for /f "tokens=1-4 delims=:., " %%A in ("%time: =0%") do @set UNIQUE=%yy%%mm%%dd%%%A%%B%%C%%D ENDLOCAL & IF "%~1" NEQ "" (SET %~1=%UNIQUE%) ELSE echo.%UNIQUE% EXIT /b :errmsg echo.%date% %time% %_errmsg% pause :end ENDLOCAL REM set _ REM pause