Last active
December 8, 2017 15:59
-
-
Save stekhn/05fe82c6316fb3bee8ec503bbf5a306e to your computer and use it in GitHub Desktop.
Bash script to count the total number of pages of multiple PDFs in a folder.
This file contains hidden or 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=0 | |
if [ "$1" != "" ] | |
then | |
dir=$1 | |
else | |
dir=. | |
fi | |
for file in "$dir"/*.pdf | |
do | |
pages=$(mdls -raw -name kMDItemNumberOfPages "$file") | |
sum=$(($sum+$pages)) | |
done | |
echo $sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment