Last active
July 6, 2023 19:13
-
-
Save johnghill/5e6b228191fb152663e58d760d499dc9 to your computer and use it in GitHub Desktop.
[bash] Count pages in all PDFs in current folder and its sub folders
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
#!/bin/bash | |
# Based on https://gist.github.com/pmalek/8521413 | |
sum_pages=0 | |
while IFS= read -r file; do | |
cur_pages=$(pdfinfo "$file" | awk '/Pages/{print $2}') | |
echo "pdf: $file has $cur_pages pages." | |
sum_pages=$(( sum_pages + cur_pages)) | |
done < <(find . -name "*.pdf" -type f) | |
echo "All pdf files in this directory and its subdirectories have $sum_pages pages." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment