(view source code of pdf2jpg.bat as plain text)
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
:: Check Command LineIF "%~1"=="" GOTO Syntax
IF NOT EXIST "%~1" GOTO InvalidPDF
IF /I NOT "%~x1"==".pdf" GOTO InvalidPDF
IF NOT "%~2"=="" GOTO Syntax
:: Find GhostScript executableSET ProgDir=
SET ProgFile=
FOR /F "tokens=*" %%A IN ('REG.EXE Query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /f Ghostscript ^| FIND.EXE /I "HKEY_"') DO (
FOR /F "tokens=2*" %%B IN ('REG.EXE Query "%%~A" /v UninstallString') DO (
SET ProgDir=%%~dpC
))IF "%ProgDir%"=="" GOTO NoGhostScript
FOR /F "tokens=*" %%A IN ('DIR /B /S "%ProgDir%gswin*c.exe"') DO SET ProgFile=%%~fA
IF "%ProgFile%"=="" GOTO NoGhostScript
:: Run GhostScriptPUSHD "%~dp1"
"%ProgFile%" -dSAFER -dBATCH -dNOPAUSE -sDEVICE=jpeg -r600x600 -sOutputFile="%~n1.%%d.jpg" "%~nx1"
POPD
ENDLOCAL
GOTO:EOF
:InvalidPDFECHO.
ECHO ←[0;1;31mERROR:←[0m Please specify a valid PDF file
GOTO Syntax
:NoGhostScriptECHO.
ECHO ←[0;1;31mERROR:←[0m GhostScript not found
:SyntaxECHO.
ECHO PDF2JPG.bat, Version 1.00 for Windows 10
ECHO Use GhostScript to convert a PDF file to JPG images
ECHO.
ECHO Usage: ←[0;1m%~nx0 "pdffile"←[0m
ECHO.
ECHO Where: ←[0;1mpdffile←[0m is the PDF file to be converted
ECHO.
ECHO Notes: The resulting images will be saved in the same folder under the
ECHO same name as the PDF, but with extension ←[0;1m.n.jpg←[0m, where ←[0;1mn←[0m
ECHO is 1..the number of pages in the PDF file.
ECHO Existing JPG files will be overwritten without prompt for confirmation.
ECHO This batch file requires GhostScript to convert PDF to JPG.
ECHO GhostScript can be found at ←[0;1;30mhttps://www.ghostscript.com/←[0m
ECHO.
ECHO Written by Rob van der Woude
ECHO https://www.robvanderwoude.com
ENDLOCAL
EXIT /B 1
page last modified: 2025-10-11; loaded in 0.0068 seconds