Use Mac OS X Automator and Services To Speed Up Repetitive Tasks

“Automator”:automator is one of best kept secrets in Mac OS X. It’s kind of like drag-and-drop scripting that lets you create workflows to automate and speed up repetitive tasks. In Snow Leopard, you can use Automator to create your own services that are accessible via the Services menu and can also be contextual, showing up when you right-click on an item like text selections or files and folders.

The Automator application lets you build a workflow by choosing from a collection of actions, some native to OS X, some installed by other applications, and dragging those actions into a workflow. There are actions that perform standalone tasks like copying a file to a specific folder, processing an image, or asking for input. If you need something more advanced there are actions that let you run shell commands, or even call other scripting languages like Python, Perl, or Apple’s own AppleScript. Combining these actions into a workflow lets you automate just about anything.

Addressing an Envelope Using Selected Text
I recently received a request to mail some additional information for a rebate I submitted several weeks ago. The email message contained the mailing address for the fulfillment center. Ordinarily, this means either hand addressing an envelope or going through several steps to launch Pages, choose a template, cut and paste the address, and print the envelope. It felt like I should be able to select the address and have an envelope automatically prepared and ready to print, but there is no built in way to do this.

Using Automator, I created a service that appears as a contextual menu item when working with selected text… in this case an address. In this workflow the Automator service is essentially a wrapper around AppleScript which does the heavy lifting here.

Automator envelope workflow

Here is the AppleScript that makes it happen.

on run {input, parameters}
	-- set the name of Envelope template to use
	set theTemplate to "Classic Envelope"
	-- set selection to first item of input list, ignore rest
	set theSelection to item 1 of input as text
	tell application "Pages"
		-- launch Pages without "Template Chooser"
		launch
		try
			make new document with properties {template name:theTemplate}
		on error
			-- display msg if the template does not exist
			display alert ¬
				"Template does not exist or
the document could not be created" buttons {"Cancel", "OK"} as warning
			-- If can't create document, then bail out of the whole shebang!
			quit application "Pages"
			return
		end try
		tell the front document
			--delete the default template text and make a new paragraph
			delete every paragraph
			make new paragraph at beginning
			tell body text
				-- put the selected text into the new paragraph
				set paragraph 1 to theSelection
			end tell
		end tell
		-- open the print dialog ready to print! Enclose in try block to ignore errors
		try
			print the front document with print dialog
		end try
	end tell
	return input
end run

Download All Links on a Web Page
There is a great add-on for “Firefox”:ff called “DownThemAll”:dta that lets you download all the links on a web page without the need to click on each link individually. I have not been able to find anything like it for Safari. I wanted to download several zip archives containing sample code for a tutorial I was working through and was certain this could be done using Automator. In just a few minutes I hacked together a workflow that finds links on the current Safari page, filters them by extension, and displays a list for me to select from, before downloading the links to the Downloads folder. This workflow makes use of several Safari specific actions.

Automator download all workflow

Copy or Move Files and Folders to iTunes
One of the easiest ways to add songs to iTunes is by copying audio files or folders containing songs to the aptly named Automatically Add to iTunes folder. While this is relatively easy, why not save a few mouse clicks and drags by adding a service to the contextual menu for Finder items like files and folders. Add one service to copy files or folders, and a second to move them.

Automator copy to iTunes workflow

I have services that copy and move files to my “Dropbox”:db folder, create tar archives from selected files and folders, and even automatically shorten a selected URL with “bit.ly”:bitly. Automator includes actions for working with text files, creating PDF documents, and even processing images. There is really no limit to the cool things you can do with Automator.

Resources
There are lots of great places online where you can find workflows. The best place to start is at “Mac OS X Automation”:osxautomation where you will not only find sample services, but some great tutorials about Automator and AppleScript.

Using Automator to build workflows is simple and takes little time to learn. Services are an effective way to automate repetitive tasks that save time. Make your computer work for you now by creating a few services of your own.

[automator]http://support.apple.com/kb/HT2488
[ff]http://mzl.la/dUTkIB
[dta]http://bit.ly/emqgQS
[db]http://db.tt/SVZWzX3
[bitly]http://bit.ly
[osxautomation]http://www.macosxautomation.com/services/download/index.html

Steve Jobs On Digital Rights Management (DRM)

Today “Steve Jobs(Steve Jobs)”:http://www.apple.com/pr/bios/jobs.html takes on the controversial topic of DRM(Digital Rights Management). In a “post on Apple’s website(Thoughts on Music)”:http://www.apple.com/hotnews/thoughtsonmusic/, Steve Jobs provides some background on DRM and the role it plays in Apple’s ability to offer music in the “iTunes Store(iTunes Store)”:http://www.apple.com/itunes/store/. He concludes by offering some compelling reasons to scrap DRM.

Jobs cites figures regarding the number of iPods sold, and the number of songs sold through the iTunes store. Perhaps most interesting is the number of songs sold online, compared to the number of songs sold on CD. According to Jobs, the figures for 2006 are:

* < 2 billion songs sold online worldwide (with DRM)
* > 20 billion songs sold completely DRM-free on unprotected on CDs by the music companies themselves

If these figures are valid, DRM is protecting _less than 10%_ of all the songs sold last year. There is absolutely nothing to stop anyone from ripping 90% of all the music sold last year into completely DRM-free tracks, and distributing them illegally. It appears that DRM has simply managed to make it more difficult to use and enjoy a small number of legally purchased songs.

Jobs talks about the practicality and impact of DRM in it’s current state, and some of the technical problems that come with developing and maintaining a DRM system. He outlines three possible alternatives going forward, but ultimately calls on the big music companies to “abolish” DRM, saying:

bq. Imagine a world where every online store sells DRM-free music encoded in open licensable formats. In such a world, any player can play music purchased from any store, and any store can sell music which is playable on all players. This is clearly the best alternative for consumers, and Apple would embrace it in a heartbeat.

The big question is, why should the recording industry dump DRM? The simple answer according to Jobs is, because it doesn’t work. What benefits are gained from DRM? Jobs says:

bq. There appear to be none. If anything, the technical expertise and overhead required to create, operate and update a DRM system has limited the number of participants selling DRM protected music. If such requirements were removed, the music industry might experience an influx of new companies willing to invest in innovative new stores and players. This can only be seen as a positive by the music companies.

If that’s the case, why does the recording industry continue to shove DRM down the throats of online distributors and consumers alike?

One can assume that the music companies look forward to a day when all music will be sold exclusively online. If the recording industry never backs down, and DRM becomes firmly rooted and accepted by the consumer, they will have greater control over distribution, and personal choice than ever.

I hope that doesn’t happen.

Apple On Vista’s New Security Features


These ads always make me laugh. This one apparantly hasn’t been released yet, but it’s making it’s way around pretty quickly. I have to admit, after using “Vista(Windows Vista)”:http://www.microsoft.com/windows/products/windowsvista/default.mspx a couple of times recently, this ad really hits home.

Apple Enables Windows XP on Intel-based Mac

The moment everyone has been waiting for? Apple Introduces Boot Camp. This beta offering is designed to allow Intel-based Macs to run Windows XP, and will become a feature in an upcoming OS X release. From the PR release:

Apple(R) today introduced Boot Camp, public beta software that enables Intel-based Macs to run Windows XP. Available as a download beginning today, Boot Camp allows users with a Microsoft Windows XP installation disc to install Windows XP on an Intel-based Mac(R), and once installation is complete, users can restart their computer to run either Mac OS(R) X or Windows XP. Boot Camp will be a feature in “Leopard,” Apple’s next major release of Mac OS X, that will be previewed at Apple’s Worldwide Developer Conference in August.

“Apple has no desire or plan to sell or support Windows, but many customers have expressed their interest to run Windows on Apple’s superior hardware now that we use Intel processors,” said Philip Schiller, Apple’s senior vice president of Worldwide Product Marketing. “We think Boot Camp makes the Mac even more appealing to Windows users considering making the switch.”

Boot Camp simplifies Windows installation on an Intel-based Mac by providing a simple graphical step-by-step assistant application to dynamically create a second partition on the hard drive for Windows, to burn a CD with all the necessary Windows drivers, and to install Windows from a Windows XP installation CD. After installation is complete, users can choose to run either Mac OS X or Windows when they restart their computer.

Big news? Maybe big enough to get me to switch. Windows XP would still be my OS of choice, not because I think it is the superior OS, but simply because I am so “locked-in”. It would be nice to leverage all the goodness of OS X for design and development, and of course the Mac would look so much better on my desk. Hmm…

Via: Paul Thurrott