Posts Tagged ‘ pdftk

pdftk cont’d…

I recently had cause to export many hundreds of email messages to .pdf. I’ll save you the details as to why but subsequently I needed to know the cost (in time and paper usage) of printing out all of the PDF files; how many pages would it be? How could I know? I previously posted about pdftk so I assumed it would provide me the answer. A bit of Googling led me to commandlinefu and the following solution.

find . -name "*.pdf" -exec pdftk {} dump_data output \; | grep NumberOfPages | awk '{s+=$2} END {print s}'

It worked like a charm.

The answer was “515” pages. Too many I think.