Total PDF pages in subfolders across folder structure
Last week, I wrote a script that ran through a folder structure and output the page count of every PDF in all folders and sub-folders, and also spit out a grand total.
While this worked well, what I really wanted was a script that just totaled PDF pages by sub-folder, without seeing all the file-by-file detail. After trying to retrofit the first script, I realized that was a waste of time, and started over from scratch.
The resulting script works just as I'd like it to, traversing a folder structure and showing PDF page counts by folder:
$ countpdfbydir
47: ./_Legal
2: ./_Medical-Dental
15: ./_Medical-Dental/Kids
11: ./_Medical-Dental/Marian
2: ./_Medical-Dental/Rob
35: ./_Personal Documents/Kids
87: ./_Personal Documents/Marian
28: ./_Personal Documents/Rob
10: ./_Personal Documents/Rob/Golf
12: ./_Personal Documents/Rob/Travel
-------------------------------------------------------------------
249: Total PDF Pages
It took a few revisions, but I like this version; it even does some simplistic padding to keep the figures lined up in the output.