Contents  EagleFiler Manual  Technical Support

7.3   Writing Stationery Scripts

The New Record ‣ Open Stationery Folder section describes the basics of EagleFiler’s stationery feature. You can also write stationery AppleScripts to set the filename and metadata. This provides more control—for example, you can set a title that’s distinct from the filename. It also lets you set the metadata dynamically—that is, it can be determined when making new records from the stationery rather than when the stationery is first created. Therefore, the metadata can be based on the current date, the current user, the current iTunes track or chat status, or any other information that’s accessible via AppleScript.

Where to Put Stationery Scripts

To set the metadata via AppleScript, create a compiled script file next to your stationery file. If the stationery file is Journal Entry.rtf, the script should be called Journal Entry.efmeta.scpt. EagleFiler will automatically run the script when you create a new record from the Journal Entry.rtf stationery.

Example Stationery Script

Here’s an example script:

on metadata(_context)
    set _title to "Blog Entry"
    set _base to do shell script "date '+%A, %B %d, %Y'"
    set _systemInfo to system info
    set _from to long user name of _systemInfo
    set _tags to {"journal", "draft"}
    return {|title|: _title, |basename|: _base, |fromName|: _from, |tags|: _tags}
end metadata

This would set the title to “Blog Entry”, the filename would be based on the current date (e.g. “Tuesday, October 21, 2008.rtf”), the from would be the name of the user logged into the Mac (e.g. “John Appleseed”), and the tags would be “journal” and “draft”.

Stationery Script Details

The script should contain a handler called metadata with a single context parameter.

The context is an AppleScript record containing the following keys: |folderName|, |libaryPath|, |stationeryBasename|, |stationeryName|, and |stationeryPath|. The script can ignore the context, or it can use it to find out about the stationery file and where the record will be created.

The metadata handler should return an AppleScript record containing one or more of the following keys: |basename|, |fromName|, |note|, |sourceURL|, |tags|, |title|.

     Contents  EagleFiler Manual  Technical Support