Created
          August 1, 2015 11:29 
        
      - 
      
- 
        Save forabi/b48a66af41f439df27e9 to your computer and use it in GitHub Desktop. 
    Get total page count for all PDF files in the current working directory. Requires pdfinfo
  
        
  
    
      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 | |
| num_pages=0; | |
| for file in *.pdf; do | |
| f_pages=$(pdfinfo "$file" 2>/dev/null | grep Pages | cut -d ":" -f 2 | sed -e 's/^[ \t]*//') | |
| if [[ -z $f_pages ]]; then | |
| echo "Error in $file" && exit 1; | |
| fi | |
| num_pages=$(( num_pages + $f_pages )) | |
| done | |
| echo $num_pages; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment