MacOS – Count pages in PDF (for non-technical, mac using person)

adobemacospdfspotlightterminal

I have a person who is looking to count pages of her perhaps 2-3000 PDFS. Unfortunately I am away and not sure what to do. She is non-technical. She needs a total count, of all the pdfs, combined (it will probably some something like 20,000 spread across the 3,000 PDFs) – no other details are necessary.

I considered adobe combine and then get a page count, but just testing on ~500 files, it is pretty slow going!

Adobe is an option.

I suppose terminal is an option too, but I'm not sure how to explain this to her. I think most of these work via spotlight indexing.. not sure about that. Not sure they are all indexed, or that this is the actual way it works.

Worth mentioning you used to be able to open multiple pdfs simultaneously in preview and get a page count! Used to work pretty well even across 2-300 files!

Thoughts?

Best Answer

Simple.

Create an Apple Script and export it as an Application and then send the Application to her.

AppleScript Code:

set totalPages to 0
set numDocs to 1
set myFiles to choose file with prompt "Select all PDF's" with multiple selections allowed
set nummyFiles to length of myFiles
set progress total steps to nummyFiles
set progress completed steps to 0
set progress description to "Processing PDF's..."
set progress additional description to "Preparing to process."
repeat with i in myFiles
    set progress additional description to "Processing PDF " & numDocs & " of " & nummyFiles
    set progress completed steps to numDocs
    set myfile to POSIX path of i
    set pageCount to (do shell script "/usr/bin/mdls " & quoted form of myfile & " | /usr/bin/awk '/kMDItemNumberOfPages/{print $3}'") as integer
    set totalPages to (totalPages + pageCount)
    set numDocs to (numDocs + 1)
end repeat
display dialog "There are " & totalPages & " pages in this PDF"
  1. Open /Applications/Utilities/Script Editor.app
  2. File>New
  3. Copy and Paste above code
  4. File>Export
  5. File Format: Application
  6. Send Exported Application