Latest in Mac automation

Image credit:

Mac Automation: Looping Workflows

Cory Bohon

Sometimes when working with Automator, you might want a workflow to loop (or go back to the first step and continue to run through the workflow). Automator includes an easy-to-use "Loop" action, and in this Mac Automation post, I'm going to show you how to use it.

Let's take a previous workflow that I wrote about: iCal to-dos. In this how-to, we got iCal to-dos sent to your mobile device via a simple workflow and e-mail. The method that I wrote about required you to send an email (and rely on mail rules) in order to retrieve your to-dos. However, with the looping action in Automator, you can easily automate this process.

Let's first build out the workflow by placing the following actions together (in the same order):

  • Find Calendars In iCal
  • New Mail Message
  • Send Outgoing Messages
  • Pause
Continue reading to learn more about the loop action.

In the "Find iCal Items" action, select "To Dos" from the "Find" drop-down menu. In the "Whose" section, select "Due Date" from the "From" box and "Today" from the second box. You can deviate from the instructions on this step and use the settings that allow you get the most use out of this workflow (for instance, you can select any interval of time you want, etc.).

In the "New Mail Message" action, enter your email address in the "To" field -- this is the address that your ToDo list will be sent to. Fill in a descriptive subject line like "My ToDo Items for Today" or something similar. Be sure to select an email account that your remote device can access.

Here's where we will differ from the original workflow -- instead of setting up mail rules, we will add the "Loop" action to the end of this workflow -- this will make the to-do process totally automatic.

When you add the Loop action, you'll notice that there are several options included to give you control on how the workflow will be looped. In the first drop-down box you will notice that there are two options: Ask to continue and Loop Automatically. The ask to continue option will prompt the user to accept a continuance of the workflow; the user will be asked to select either "Continue" or "Don't Continue" from a pop-up dialog.

We will be using the "Loop automatically" option for this workflow. When you select this option you will be asked to specify either how many times or how many minutes. This limitation keeps you from accidentally creating an infinite loop (not Apple's address, but a programming error known as an infinite loop).

This is where the Pause and Loop actions work together. If you wanted your to-do list to be sent 2 times a day, you could input "2 times" in the Loop action, and specify 43,200 seconds (half of 24 hours in seconds) for the Pause time. This would cause your to-do list to be sent twice a day, then stop.

As you can see, Automation on the Mac is powerful, and the loop action adds to that power. We'll be using the loop action more in future Mac Automation posts, so be sure to stay tuned. And if you want to read more about Automator then be sure to visit our Mac Automation page.

From around the web

ear iconeye icontext filevr