@ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION :: Check Command Line IF "%~1"=="" GOTO Syntax IF NOT EXIST "%~1" GOTO InvalidPDF IF /I NOT "%~x1"==".pdf" GOTO InvalidPDF IF NOT "%~2"=="" GOTO Syntax :: Find GhostScript executable SET 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 GhostScript PUSHD "%~dp1" "%ProgFile%" -dSAFER -dBATCH -dNOPAUSE -sDEVICE=jpeg -r600x600 -sOutputFile="%~n1.%%d.jpg" "%~nx1" POPD ENDLOCAL GOTO:EOF :InvalidPDF ECHO. ECHO ERROR: Please specify a valid PDF file GOTO Syntax :NoGhostScript ECHO. ECHO ERROR: GhostScript not found :Syntax ECHO. ECHO PDF2JPG.bat, Version 1.00 for Windows 10 ECHO Use GhostScript to convert a PDF file to JPG images ECHO. ECHO Usage: %~nx0 "pdffile" ECHO. ECHO Where: pdffile 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 .n.jpg, where n 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 https://www.ghostscript.com/ ECHO. ECHO Written by Rob van der Woude ECHO https://www.robvanderwoude.com ENDLOCAL EXIT /B 1