(view source code of pdfpagecount.bat as plain text)
@ECHO OFF
IF "%~1"=="" GOTO Syntax
IF /I NOT "%~x1"==".PDF" GOTO Syntax
IF NOT EXIST "%~1" GOTO Syntax
SETLOCAL ENABLEDELAYEDEXPANSION
SET Count=0
FOR %%A IN (%*) DO (
SET /A Count += 1
SET PageCount=0
FOR /F %%B IN ('TYPE "%%~A" 2^>NUL ^| FINDSTR /R /C:"/Type[ ]*/Page" 2^>NUL ^| FIND /V "/Pages" ^| FIND /C "/Page"') DO SET PageCount= %%B
SET PageCount=!PageCount:~-3!
IF !PageCount! EQU 1 (
ECHO 1 page "%%~A"
) ELSE (
ECHO !PageCount! pages "%%~A"
)
)
IF %Count% GTR 1 SET PageCount=0
ENDLOCAL & EXIT /B %PageCount%
:Syntax
ECHO.
ECHO PDFPageCount.bat, Version 1.01
ECHO Return the page count for the specified PDF file(s)
ECHO.
ECHO Usage: PDFPAGECOUNT filespec [ filespec [ filespec [ ... ] ] ]
ECHO.
ECHO Where: filespec is the file specification of the PDF file(s)
ECHO to be checked; wildcards are allowed
ECHO.
ECHO Note: If a single file is specified, return code will equal page count.
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
page last modified: 2024-04-16; loaded in 0.0052 seconds