How to count pages in multiple PDF files?

I just received a pdf textbook comprised of some 20 separate pdfs (by chapter) with quasi-regular names. Is there a way for counting the pages in the book without opening each file (or going through the properties)? [solution can be for Windows or Ubuntu]

22k 56 56 gold badges 215 215 silver badges 364 364 bronze badges asked Mar 22, 2012 at 16:21 2,690 13 13 gold badges 51 51 silver badges 80 80 bronze badges Do you have Adobe Acrobat? Commented Mar 22, 2012 at 16:34 Do you want the page count for each PDF file, and/or the entire book? Commented May 19, 2019 at 1:59

@FranckDernoncourt - thanks. The question was asked some 7 years ago. If you have a solution to either ways you mentioned, why won't you just add an answer here, so future users researching this issue can refer to?

Commented May 28, 2019 at 11:59

7 Answers 7

Using pdfinfo this is the best I could come up with: To print the number of pages per file:

for i in *.pdf; do echo $i && pdfinfo "$i" | grep "^Pages:"; done 

To print the sum of all pages in all files:

for i in *.pdf; do pdfinfo "$i" | grep "^Pages:"; done | awk ' END ' 

On Ubuntu, pdfinfo is contained in the package poppler-utils . To install it, use:

sudo apt-get install poppler-utils 

On Windows, you can use cygwin. pdfinfo is contained in the package poppler .

103 3 3 bronze badges answered Mar 22, 2012 at 16:43 Oliver Salzburg Oliver Salzburg 88.1k 64 64 gold badges 266 266 silver badges 308 308 bronze badges

+1 pdfinfo is exactly what I was looking for. I need it for page counts in my duplex printing emulation package.

Commented Mar 12, 2013 at 6:18

I had to add the --text flag to the grep command, because for some reason pdfinfo returned something that grep interpreted as a binary file. So grep --text "^Pages:", just in case someone else has the same issue.

Commented Feb 13, 2020 at 14:27

I know its too late but I just found a way better and simpler solution for this.

Download and install from sourceforge "pdf split and merge"

Drop all your files on it, and in the screen it generates a spreadsheet-like report on the number of pages and info of each.

Select that, copy, paste into excel or opencalc, you got it.

answered Jun 29, 2014 at 11:19 user339697 user339697 41 1 1 bronze badge

I made an application just for this, Its written in Java so works on all os's. Check it out here:

Its best to run the application from terminal ( java -jar ) to ensure it will work properly.

Put the jar file in the directory you want to get the page count of all the pdfs in. It will cycle through subfolders aswell, no need to place all the pdfs where the jar file is as it will cycle through the subfolders where you place the jar file. Double click on the jar, it may take some time if there is alot of pdfs, it will eventually output a txt file in the same directory of the jar file, and it will have the page count within it.