Created
November 18, 2012 12:36
-
-
Save Paretzky/4105017 to your computer and use it in GitHub Desktop.
Total the Number of Pages in All Pdf's in the Current Directory Recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -type f -iname "*pdf" | xargs -0 -d "\n" -n 1 pdfinfo 2> /dev/null | grep Pages | grep -Eo "[[:digit:]]+" | tr "\n" "+" | grep -Eo "[[:digit:]]+(\+[[:digit:]]+)+" | bc |
I was printing off a bunch of papers to read on a trip. Before just sending all of them off as one big print job I wanted to see how many pages of my quota that would actually take.
Oh yeah, pdfinfo sometimes spits out extra stuff when it has issues parsing a pdf completely. The answer, in my minimal works for me style testing, will always be the last line outputed.
4983541063155bb5583946cdc5863c5830f9da6a add case insensitive matching *pdf files, and removes pdfinfo's stderr complaints.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
... while this is awesome, it's also one of those "why would you ever need this" moments.