Creating a Conversion Action
A conversion action acts as a kind of bridge between two actions whose types of provided data (
AMProvides property) and accepted data (
AMAccepts) do not match. The conversion action converts between one type and another, usually from an internally defined data type (such as an iTunes track object, specified by the UTI identifier
com.apple.itunes.track-object) to an externally defined public type (such as a file, specified by
Automator does not display conversion actions and users do not have to bother placing them between actions. The application determines if there is a data-type mismatch between two actions and, if a suitable conversion action is available, it inserts it invisibly between them. Conversion actions have a bundle extension of
.caction and are installed in the usual system directories for actions.
You create a conversion action just as you would a “normal” action (as described in “Developing an Action”) but with just a few differences:
Set the extension of the produced bundle to
.caction. To do this, select the action target and choose Get Info from the Project menu. In the Build pane of the Info window (Customized Settings collection), set the Wrapper Extension to “caction”.
In the information property list (
Info.plist) for the bundle be sure to do the following:
AMAcceptstype identifier should specify the type of data converted from.
AMProvidestype identifier should specify the type of data converted to.
AMCategoryproperty should have a value of “Converter/Filter”.
AMApplicationproperty value should be “Automator”.
See Listing 1 for an example.
Of course, there is no need for an action description, nib file, or similar resource.
Listing 1 Typical Automator properties for conversion actions
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<string>(* The name of the icon *)</string>
<string>Convert Photo object to Alias object</string>
<!- other properties here -->
As the final step, write the script or Objective-C source code to do the conversion. The script example in Figure 1 converts iPhoto objects representing photo images to paths to those images in the file system.