Learning How to Automate Your Mac by Example


Once you understand the general way the Automator works and how you should go about building workflows, the only way to really learn how to create your own workflows is to start creating them. The first few you create might take a while, but as you gain more experience with Automator, you'll become more proficient creating new workflows. To get you started, in this section you'll find three sample workflows you can re-create on your Mac. Doing this will give you some experience using the Automator; then you'll be ready to start designing and creating your own workflows.

TIP

Automator includes some built-in workflow examples. To see them, expand the Example Workflows folder and double-click a sample workflow. A new Automator window will open and you will be able to view and work with the sample workflow.


Opening Websites

If you visit the same websites regularly, you can create a workflow and application that opens Safari for you and takes you to as many websites as you'd like. To create this workflow, perform the following steps:

To learn how to use Safari to browse the Web, p. 460.


1.

Launch the Automator.

2.

In the Library pane, select Safari. You'll see the actions available for that application in the Action pane.

3.

Select the "Get Specified URLs" action. In the Information area, you'll see an explanation of the action ("This action passes the specific URLs into the next action.") along with its results (URLs).

4.

Drag "Get Specified URLs" from the Action pane onto the Workflow area (see Figure 10.6). In the center of this action is a table that will contain each URL you want to open. By default, Apple's home page is on the list of URLs that will be opened.

Figure 10.6. The "Get Specified URLs" action is now part of this workflow.


TIP

To remove a URL, such as the Apple home page, from the list of URLs, select it and click the minus (-) button.

5.

Click the Add New Item button (+). A new address will appear on the list.

6.

Double-click the Bookmark portion of the URL line so it becomes highlighted, and then enter a name for the website.

7.

Press Tab so the Address part of the URL line becomes highlighted, and then type the URL.

TIP

You can add a website more easily by opening it in Safari and clicking the Current Safari page button. The URL of the current web page will be added to the URL list.

8.

Continue adding URLs until you have all that you want to be opened in the list.

TIP

To test a URL on the list, select it and click Open URL. Safari will launch and move to the URL.

9.

Select the "Display Webpages" action. In the Information area, you'll see that this action displays web pages in Safari when provided with URL addresses. Its input is URL addresses and its output is Safari documents.

10.

Drag the "Display Webpages" action onto the Workflow area and drop it after the "Get Specified URLs" action (see Figure 10.7).

Figure 10.7. This workflow now has two actions.


11.

Check that the output of the first action, which is URLs, matches the input of the section action, which is also URLs. Notice how the output arrow of the first action fits into the input receptor of the second to graphically show you that the output and input of these actions match.

NOTE

If the output of one action doesn't match the input of the next, Automator will mark them in red and the arrow from the output won't fit into the input receptor of the action receiving the output. This indicates a mismatch, meaning that the workflow won't work properly.

12.

Click the Run button. Automator will run the workflow. As each action runs, you'll see a progress wheel in the lower-left corner of the Action. When it completes, this will become a check mark to show you the action was completed successfully. The next action will run in the same way. When the entire workflow is done, you'll hear a tone.

13.

Switch to Safari and you'll see that a Safari window has opened for each URL that is part of your workflow (see Figure 10.8).

Figure 10.8. Here you can see that the four URLs that are part of the workflow have been opened in Safari.


14.

Choose File, Save; name the workflow; and save it.

TIP

By default, workflows you save are stored in the My Workflows folder. You can view these in the Automator by expanding the My Workflows folder in the Library pane.


After you have created and tested a workflow, you can save it as an application so you can run it just like other applications. To create an application from a workflow, perform the following steps:

1.

Open the workflow you want to save as an application. It will open in Automator.

2.

Choose File, Save As. The Save As sheet will appear.

3.

Name the application (you can use the same name as the workflow if you want because they are different types of files, so you don't have to worry about replacing the workflow).

4.

Choose the location in which you want to save the application you are creating. Consider creating a folder in which to store all your applications so you can locate them easily. For example, you might want to create a folder called My Applications within the Applications folder.

5.

On the File Format pop-up menu, select Application.

6.

Click Save. An application will be created from the workflow.

7.

Open the location you selected in step 4. You'll see the application you created (see Figure 10.9).

Figure 10.9. To open a number of websites at the same time, all I have to do is run this application.


8.

Launch the application by opening it. The application will run; as it does, you'll see the application name and progress information in the menu bar.

Just like other applications on your Mac, you can open an application you've created in many ways, such as by adding it to the Dock and clicking its icon, adding it to the Places sidebar and clicking its icon, adding it to your Login items, and so on.

Sending Files via Email

For this example, suppose that you regularly send files to someone via email (maybe you are an author and you send your chapters to your editor). You can create a workflow that will archive files you select in a Zip file, create and address an email, and attach the Zip file to the email. Here's how to create this workflow:

To learn how to configure Mail, p. 418.


1.

Launch Automator or select File, New to create a new workflow.

2.

Click the Finder application and then click the "Get Selected Finder Items" action. You'll see that this action gets items you have selected in the Finder and passes them to the following action.

3.

Drag the "Get Selected Finder Items" action onto the workflow.

4.

Select the "Create Archive" action (which creates a Zip archive of files or folders), drag it onto the workflow, and place it after the "Get Selected Finder Items" action. Notice that the output of the first action (Files/Folders) matches the input of the second one (also Files/Folders).

Next, you will configure the Create Archive action so that you are prompted to name the archive file and choose a location each time you run the workflow. (If you wanted the archive file to be named the same and stored in the same location each time, you could enter the filename in the Save As box and select the location on the Where pop-up menu.)

5.

Expand the Options area by clicking the expansion triangle (see Figure 10.10).

Figure 10.10. This workflow has two actions; the Options area for the second action is expanded.


6.

Check the "Show Action When Run" check box and the "Show Entire Action" radio button. When you run the workflow, this will cause the Save As dialog box to appear so that you can name the archive file and choose its save location.

TIP

You can expand or collapse the details for a step by clicking its expansion triangle. As you add actions to a workflow, its window will become full. Collapsing actions you have configured makes it easier to view the contents of the workflow.

7.

Select the Mail application and then drag the "New Mail Message" action into the workflow and place it below the "Create Archive" action. Notice that the output of the "Create Archive" action (Files/Folders) fits with the input of the "New Mail Message" action (also Files/Folders).

TIP

In some cases, the input to an action will contain a downward-pointing arrow. This is a pop-up menu you can use to choose options for the action's input. For example, if you select "Use Results from Previous Action" on this menu, the output of the previous step will be used for the current step. If you select "Ignore Results from Previous Action," the previous step's output will be ignored.

8.

Enter the email address for the person to whom you want to send the file in the To box or click the Address Book icon to select an address in your Address Book.

9.

Type a subject for the message in the Subject field.

10.

If you want some text to appear in the message every time, enter it in the Message box.

11.

Choose the email account that should be used to send the message on the Account pop-up menu.

12.

Review the workflow to see whether the actions you need it to run are available, configured, and in the correct order (see Figure 10.11).

Figure 10.11. This workflow is almost ready to test.


13.

Save the workflow.

CAUTION

You should always save a workflow before you run it. If it doesn't work properly, Automator might quit, in which case you could lose your workflow.


Now that you have created the workflow, it is time to test it by performing the following steps:

1.

Move to the Finder and select one or more files.

2.

Move back into the Automator and click Run to run the workflow. The first step will get the files you selected. When the second step runs, you will see the Create Archive dialog box (see Figure 10.12).

Figure 10.12. Your application will prompt you to name the archive and choose a location into which to save it.


3.

Name the archive file, select the location in which you want it saved, and click Continue. The workflow will create the archive. Then, the next step in the workflow will create a new email message; attach the archived file; and enter the address, subject, and body text (see Figure 10.13). You'll hear the workflow's "completed" tone when it has finished its work.

Figure 10.13. This email was created by the workflow and is just about ready to send it.


4.

Make any changes needed to the message, such as adding or changing the text.

5.

Click Send to send the message.

If the workflow works the way you want it to, save it as an application. You can send files by selecting them in the Finder and running your application.

TIP

If you want to use the workflow to send files to different people, you could leave the To box empty and fill it in when the workflow is done.


Backing Up Files on CD

Backing up important files is always something you should do. It is a good idea to obtain and use software dedicated to that purpose, but this example workflow can be used in a pinch. It will identify files in your Documents folder that have changed in the past two weeks, create a disk image containing those files, and put the disk image on a CD. To build this workflow, perform the following steps:

1.

Create a new Automator workflow.

2.

Select the Finder application and drag the "Find Finder Items" action into the Workflow area. This action includes the same search tools you can use in the Finder to locate files.

3.

Select Documents from the Where pop-up menu. This tells the workflow to look only in your Documents folder.

4.

Select "Date Modified" from the first Whose pop-up menu and then select "Within Last Two weeks" from the second Whose pop-up menu. This instructs the Finder to find any file that has been changed during the past two weeks.

5.

Drag the "New Disk Image" action onto the workflow and place it after the previous action. Notice that the output of the first matches the input of the second.

6.

Select "610 MB (CD-ROM 74 min)" from the Size pop-up menu.

7.

Name the volume you will create with the disk image by entering the name in the "Volume name" box.

8.

Name the disk image file by entering a name in the "Save as" box. This can be the same name as the volume name.

9.

Choose the location in which you want to save the disk image file from the Where pop-up menu.

10.

Choose "Leave mount and return the image volume" from the "When done" pop-up menu.

11.

Select System in the Library pane and drag the "Burn a Disc" action so it is the third step in the workflow. The input to this action is Files/Folders, which matches the output of the previous action.

NOTE

If a requirement for an action is not met by your Mac, you won't be able to place it in a workflow. For example, you can't use the "Burn a Disc" action in a workflow on a Mac without a drive capable of burning a disc.

12.

Name the disc you want to burn in the Disc Name field.

13.

Check the "Append date" check box so that a new date will be added to the disc each time this workflow runs.

14.

If you have more than one burner available to you, select the burner you want to use from the "Burn Disc In" pop-up menu.

15.

If you will use erasable media, check the "Erase first" check box if you want the disc to be erased before it is burned.

16.

Check the "Verify burned data" check box if you want your Mac to make sure the disc is burned correctly.

17.

Click the "Mount on Desktop" radio button if you want the disc to be mounted on your desktop when it is done or the "Eject Disc" radio button if you want it to be ejected instead.

18.

Review the workflow and correct any issues you see.

19.

Save the workflow (see Figure 10.14).

Figure 10.14. This workflow will put all the files stored in my Documents folder and that have been modified within the past two weeks in a disk image and then burn that image onto a CD.


Test the workflow by running it. It will find all the files in your Documents folder that have been changed in the past two weeks and create a disk image file containing those files. Then, it will burn the disk image onto a disc.

TIP

It can be helpful when testing and troubleshooting to enable the "Show Action When Run" option for any actions that are complicated. When the workflow runs, you'll be prompted to complete the step; this gives you a better idea of what each of those steps is doing, which can be helpful when you are trying to find problems.


If the workflow runs properly, save it as an application so you can run it from the desktop. If not, edit it and retest it until it does work properly.

TIP

You can share your workflows with other people by providing them the workflow or application file. They will be able to use those files just like workflows or applications they create.




Special Edition Using MAC OS X Tiger
Special Edition Using Mac OS X Tiger
ISBN: 0789733919
EAN: 2147483647
Year: 2003
Pages: 317
Authors: Brad Miser

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net