Search code examples
applescriptosx-lionpreview

Is OSX Lion Preview application scriptable?


Is OSX Lion (or older OSX) release of Preview scriptable?


Solution

  • Preview is not now, and have never been AppleScript-able, which does suck. It'd be nice if it were, though.

    From this blog:

    However, from 10.4–10.6 it was possible to enable the default Cocoa scripting support via these Terminal commands:

    sudo defaults write /Applications/Preview.app/Contents/Info
    NSAppleScriptEnabled -bool YES 
    
    sudo chmod a+r /Applications/Preview.app/Contents/Info.plist 
    

    This was sufficient to be able to get at the file of the current document to delete it, change its Finder label, import it into EagleFiler, etc. Under 10.7, modifying the Info.plist file breaks the application’s code signature. I would expect this to cause a harmless warning message in the Console, but it actually causes Preview to crash.