Created
January 20, 2014 15:04
-
-
Save pmalek/8521413 to your computer and use it in GitHub Desktop.
Bash script to count pages of pdfs in current 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 | |
sum_pages=0 | |
for file in *.pdf ; do | |
cur_pages=$(pdfinfo $file | awk '/Pages/{print $2}') | |
echo "pdf: $file has $cur_pages pages." | |
sum_pages=$(( sum_pages + cur_pages)) | |
done | |
echo "All pdf files in this directory have $sum_pages pages." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks!
I suggest using "$file" instead of $file, with irregular files names