Tag PDFs that Need OCR

Summary: Adds the “NeedsOCR” tag to the selected PDF files that do not have any text.
Requires: EagleFiler
Install Location: ~/Library/Scripts/Applications/EagleFiler/
Last Modified: 2017-03-03

Description

When importing from a scanner, you might not have run your OCR program before importing the scanned document into EagleFiler. This script looks at the records that you’ve selected and tags any PDF files that have not yet been run through OCR, so that you can do so, e.g. using the OCR With PDFpen script.

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

Script

property pMinimumTextLengthThatCounts : 1

tell application "EagleFiler"
    
set _records to selected records of browser window 1
    
repeat with _record in _records
        
if _record's universal type identifier is "com.adobe.pdf" then
            
with timeout of 5 * 60 seconds
                
set _string to _record's text content
            
end timeout
            
if length of _string < pMinimumTextLengthThatCounts then
                
set _oldTagNames to _record's assigned tag names
                
set _record's assigned tag names to _oldTagNames & {"NeedsOCR"}
            
end if
        
end if
    
end repeat
end tell