Created
March 30, 2014 18:23
-
-
Save morido/9877322 to your computer and use it in GitHub Desktop.
Sum up number of PDF pages in a directory
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 | |
# This sums up the number of pages of all pdfs in a given directory | |
counter=0 | |
hash pdfinfo 2>/dev/null || { echo >&2 "pdfinfo is required, but not installed. Aborting."; exit 1; } | |
if [ -n "$1" ]; then dir=$1; else dir="."; fi | |
for file in $dir/*.pdf; do | |
currentcount=$(pdfinfo "$file" | sed -n 's/^Pages:\s*\([0-9]\+\)/\1/p') | |
counter=$((counter+currentcount)) | |
done | |
echo $counter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment