Get number of pages in a pdf using a cmd batch file
Alternatively you can use the command, which returns only the number:
pdfinfo "${PDFFILE}" | grep Pages | sed 's/[^0-9]*//'
You will need the poppler package:
https://poppler.freedesktop.org/
Which can be installed using either homebrew / linuxbrew:
brew install poppler
or with apt
:
sudo apt install poppler-utils
Using pdftk:
pdftk my.pdf dump_data | grep NumberOfPages
does the trick.