Use an automator script to add items to iCal

Use an automator script to add items to iCal
Sunday, 27 May 2012

Do you often receive emails with attached .vcs files which you must then rename manually and add to iCal? Guest author Paul Scotti explains how to make a script with Automator so in future the process takes only a single click. His script also shows how to move and rename other attachments, if that’s something you do often. [Miraz: I rewrote some of the text Paul supplied, to fit the MacTips style more closely. ]

There are several steps to set this up, but once you’ve created this shortcut it takes less than a second to rename attachments and add appointments from a vcs file to iCal. It may look long, but it’s easy to do. Give it a try!

Paul Scotti. Paul Scotti: I live in Auckland; now retired but worked as a research scientist (microbiologist; virologist) for my career. Got involved with computers as a research tool way back in 1971, writing my own programs in Basic since nothing much was available commercially back in those days. Got my first home computer in 1981 (a staggering 64 kb of memory) which used cassette tapes to load my programs! Switched to Apple at home when I got an iMac in 2001.

It’s easy to drag a file from an Apple Mail message and then manually rename a vcs file to ics to create an event using iCal, as I explained in How to rename vcs files so iCal can open them. But a simply compiled Automator script can do the job quickly and save you several steps.

Also see these older Tips: Automate It, How to rename files by adding them to a folder and Rename batches of files.

Create a new Automator Workflow


Open Automator by double-clicking its icon in the Applications folder.

The Workflow Template Chooser window appears.

Click on Workflow and then on the highlighted Choose button. An empty Workflow window appears. On the left side of the window are lists of Actions. On the right is where you build your Workflow.

The Workflow Template Chooser window.

The WorkflowTemplate Chooser window.

Save attachments

Select Mail in the Actions Library list. Then select Get Selected Mail Items from the list of Mail actions and drag it into the area to the right.

Note that when Get Selected Mail Items arrives in the Workflow area on the right it changes its name to Get Selected Mail Messages.

Next drag across Get Attachments from Mail Messages — the order is important.

By default the attachments will be put into the Downloads Folder but you can change that. To save the attachments somewhere else choose whatever location you want using the Save attachments in: pop-up menu.

The finished workflow.

The finished workflow. Want to see it at full size (200Kb)?

Rename attachments

Next click on Files and Folders in the left hand column. Drag the item Rename Finder Items into the script.

A message appears:

This action will change the names of the Finder items passed into it. Would you like to add a Copy Finder Items action so that the copies are changed and your originals are preserved?

Click the highlighted Add button to add this action.

When the Rename Finder Items arrives in the Workflow it defaults to Add Date or Time. To rename the attachments as we need for this task though you need to change that.

From the first pop-up select Replace Text.

Then put vcs into the Find: box and ics into the Replace box. Choose extension only and tick the box ignore case:.

Open in iCal

All that’s left now is to drag the Open Finder Items into the Workflow area and choose Open with: iCal.

The script should now be fully functional. Make sure to save it before you close.

Save the script

You can save the script to any location you wish but if you save it in the right place it can be really easy to use.

Save the script into [Macintosh HD]/Library/Scripts/Mail Scripts, because then you can access it from the Menu Bar (see below).

Make sure to give the script a name that is meaningful to you. I named mine ~extract from mail & change vcs to iCal. The tilde (~) at the start makes this script the first in the list.

I choose the script from the Menu Bar.

I choose the script from the Menu Bar.

Use the saved workflow

Highlight the messages in Mail which have attachments you want retrieved — the messages don’t even have to be open.

Click on the Scripts icon in the Menu Bar.

No Scripts icon in the Menu Bar? Open the AppleScript Editor (look in your Applications or Utilities folder). Choose Preferences…. Click on the General tab. Check the box beside Show Script menu in menu bar.

Select Mail Scripts and then select ~extract from mail & change vcs to iCal (or whatever you named your script).

The Automator script retrieves whatever attachments are in the email, opens iCal and adds the content of the ics files.

How does this work for you? Save you any time?

To leave a comment if you’re reading this by email or RSS feed please visit the Tip at the MacTips website. There should be a link from the title.

Related posts

[wpzon keywords="pressure cooker" sindex="PCHardware" snode="1232597011" sort="salesrank" listing="8"]