Count PDF Pages

Summary: Counts the total number of pages of the selected PDF files.
Requires: EagleFiler
Install Location: ~/Library/Scripts/Applications/EagleFiler/
Last Modified: 2021-07-28

Description

This script looks at the selected records in the records list and counts up the total number of pages of the records that are PDF files. It also looks inside any folders that are selected.

More generally, this shows how a script can recursively process the selected records in EagleFiler. For example, with slight modifications it could count the records with a certain label, tag, or kind.

Installation Instructions · Download in Compiled Format · Download in Text Format

Script

tell application "EagleFiler"
    
set _records to selected records of browser window 1
    
set _count to my countPages(_records)
    
display dialog "Total PDF pages: " & _count
end tell

on countPages(_records)
    
set _result to 0
    
repeat with _record in _records
        
tell application "EagleFiler"
            
if _record's universal type identifier is "com.adobe.pdf" then
                
set _result to _result + (_record's parts count)
            
else if _record's is folder then
                
set _result to _result + (my countPages(_record's library records))
            
end if
        
end tell
    
end repeat
    
return _result
end countPages