Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for pdfpagecount.bat

(view source code of pdfpagecount.bat as plain text)

  1. @ECHO OFF
  2. IF "%~1"=="" GOTO Syntax
  3. IF /I NOT "%~x1"==".PDF" GOTO Syntax
  4. IF NOT EXIST "%~1" GOTO Syntax
  5.  
  6.  
  7. SETLOCAL ENABLEDELAYEDEXPANSION
  8. SET Count=0
  9. FOR %%A IN (%*) DO (
  10. 	SET /A Count += 1
  11. 	SET PageCount=0
  12. 	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
  13. 	SET PageCount=!PageCount:~-3!
  14. 	IF !PageCount! EQU 1 (
  15. 		ECHO   1 page 	"%%~A"
  16. 	) ELSE (
  17. 		ECHO !PageCount! pages	"%%~A"
  18. 	)
  19. )
  20. IF %Count% GTR 1 SET PageCount=0
  21. ENDLOCAL & EXIT /B %PageCount%
  22.  
  23.  
  24. :Syntax
  25. ECHO.
  26. ECHO PDFPageCount.bat,  Version 1.01
  27. ECHO Return the page count for the specified PDF file(s)
  28. ECHO.
  29. ECHO Usage:  PDFPAGECOUNT  filespec  [ filespec  [ filespec  [ ... ] ] ]
  30. ECHO.
  31. ECHO Where:  filespec      is the file specification of the PDF file(s)
  32. ECHO                       to be checked; wildcards are allowed
  33. ECHO.
  34. ECHO Note:   If a single file is specified, return code will equal page count.
  35. ECHO.
  36. ECHO Written by Rob van der Woude
  37. ECHO http://www.robvanderwoude.com
  38.  

page last modified: 2024-04-16; loaded in 0.0052 seconds