11

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 th book w/o openning each file (or going through the properties)?

[solution can be for Windows or Ubuntu]

  • Do you have Adobe Acrobat? – wizlog Mar 22 '12 at 16:34
  • Do you want the page count for each PDF file, and/or the entire book? – Franck Dernoncourt May 19 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? – ysap May 28 at 11:59
15

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 '{s+=$2} END {print s}'

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.

  • +1 pdfinfo is exactly what I was looking for. I need it for page counts in my duplex printing emulation package. – Joe Mar 12 '13 at 6:18
4

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.

3

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

https://github.com/hamiltino/multiple-pdf-counter/releases

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.

  • Nice idea. Good enhancements would be: 1) open that is command-line only (no UI), and 2) output the page size of each file, along with total – raider33 Sep 14 '18 at 17:26
1

In Adobe Acrobat Pro, go to file > create PDF > merge files into a single PDF. Then add files and select the files you want. Click combine, and see how many pages are in the final PDF.

  • Thanks @wizlog - this really requires the full featured (and expensive) software, doesn't it? – ysap Mar 22 '12 at 17:26
  • Just noticed your comment on the question. No, I don't have it. – ysap Mar 22 '12 at 17:28
1

Hi dont know how you can do it on windows but on linux bash it should work with this

PDFS=`ls *.pdf`
counter=0
for i in $PDFS
do
   (( counter += `pdfinfo internship_report.pdf | sed -n 's|Pages:[^0-9]*\([0-9]*\).*|\1|p'`))
done
echo $counter

best reguards kenny

  • Thanks, Kenny. This may work if the filename would scan through the files. Upvoted anyway. – ysap Mar 22 '12 at 17:25
0

another approach with parallel and expr (should be a bit faster on multiprocessor machines):

expr $( echo -n 0; parallel "pdfinfo {} |sed -n 's/Pages: */ + /p'" ::: *pdf|tr '\n' ' ')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.