Contents  EagleFiler Manual  Technical Support

7.2   Writing Capture Scripts

You can extend EagleFiler’s capture key to support additional applications by adding capture scripts to the folder:

/Users/<username>/Library/Application Support/EagleFiler/Capture Scripts/

(See How can I open the Library folder?.) A capture script is an AppleScript saved in compiled format. The name of the file is of the form <bundle identifier>.scpt, e.g. You can determine an application’s bundle identifier by finding the CFBundleIdentifier in the Info.plist file inside the application’s package (which you can open using the Show Package Contents command when Control-clicking on the application).

The script should have a handler called capture that returns a list of AppleScript records. Each record in the list should have a |url| key (for a remote http URL) or a |path| key (for a full POSIX path). If no items are available for capture, the script can return the empty list, or it can return a record with a |error| key that provides an application-specific error message.

Other, optional, keys are:

If the script creates a temporary file for the capture, it can include this key with value true so that EagleFiler will delete the temporary file after it has finished importing the file.
Overrides the From name that would be extracted from the file.
A string for the note text.
The URL that the document was downloaded from.
A list of tag names.
A Unicode string of space-separated tag names, which EagleFiler will parse.
Overrides the title that would be extracted from the file.
Sets the creation date of the file.
Sets the modification date of the file.
Overrides the format chosen in EagleFiler’s preferences. Must be one of: html, pdf, pdfSinglePage, rtf, rtfd, txt, webarchive, webloc.

Example: NetNewsWire

The NetNewsWire 3 capture script looks like:

on capture()
    tell application "NetNewsWire"
        set _tabIndex to index of selected tab
        set _tagNames to {}
        set _title to ""
        set _note to ""
        if _tabIndex is 0 then
            if exists selectedHeadline then
                set _url to URL of selectedHeadline
                set _title to title of selectedHeadline
                    get _title
                on error
                    set _title to ""
                end try
                if isFlagged of selectedHeadline then
                    set _tagNames to {"flagged"}
                end if
                return {{|error|:"No URL is available to be captured."}}
            end if
            set _urls to URLs of tabs
                set _url to item (_tabIndex + 1) of _urls
                set _titles to titles of tabs
                set _title to item (_tabIndex + 1) of _titles
                    set _note to do JavaScript "window.getSelection().toString()"
                end try
            on error
                return {{|error|:"EagleFiler could not access the current tab due to a bug in NetNewsWire. Please try closing any blank tabs."}}
            end try
        end if
    end tell
    return {{|url|:_url, tags:_tagNames, title:_title, |note|:_note}}
end capture

Example: Finder

The capture script for the Finder demonstrates how to capture multiple items at once:

on capture()
    tell application "Finder"
        set theSelection to selection as list
        set theResult to {}
        repeat with theFile in theSelection
            set theFile to theFile as alias
            copy {|path|:POSIX path of theFile} to end of theResult
        end repeat
        return theResult
    end tell
end capture
     Contents  EagleFiler Manual  Technical Support