Ghostscript, postscript, pdf

Is there a command of ghostscript to get the count of pages of a pdf file?

I know there is pdfinfo but i want to do it with ghostscript.

Here two lines i found but not tested

gs -q -dNODISPLAY -c “($PATH_TO_PDF) ® file runpdfbegin pdfpagecount = quit”;

gs -q -dNODISPLAY -c “($PATH_TO_PDF) ® file runpdfbegin pdfpagecount = quit”’)
Regards lorglas

Does not get any output.

hi Lelldorin,

this line works:
gs -dNODISPLAY -dBATCH -dNOPAUSE -o /dev/null /boot/home/Desktop/ch01.pdf | grep --regex ‘^Page’ | wc -l

If you use this

gs -dNODISPLAY -dBATCH -dNOPAUSE -o /dev/null /boot/home/Desktop/ch01.pdf

you see the counter of gs.

Thanks will try

I only get 0 as output and he does not know the Page commamd

Anymore know how to merge two A4 pages to one A3 page?