How folder action scripts work

    The Standard Additions dictionary includes five commands in the Folder Actions suite:

    Open the Standard Additions dictionary for me.

    Each of these commands sends an event to the Folder Actions extension included with the Mac OS. If you attach a script to a folder that includes a handler for one or more of these commands, your script will run when the associated event occurs.

    For example, if you want a folder action script to execute when you open a folder, you include a handler for the Opening Folder command in your script:

    on opening folder my_folder
    -- statements to execute here
    end opening folder

    A script can include a handler for one or more of the five commands, but only one handler for each command. For example, a script can contain a handler for when a folder is opened and a handler for when it is closed.

    To attach a folder action script to a folder:
    1 Press the Control key and select the folder.
    2 Choose "Attach a Folder Action" from the menu that appears.
    3 Select the script using the dialog box that appears.

    While you can save folder action scripts anywhere, you may want to keep them in the Folder Action Scripts folder. This folder contains scripts included with the Mac OS. It is located in the Scripts folder in the System Folder.

Related topic

 


Table of contents