Macworld > Ask the Script Doctor: Working with Text

Ask the Script Doctor is a regular column in which we solve real-world Mac problems using AppleScript and Automator. If you have a problem you’d like us to solve, send an email to the Script Doctor for consideration.

Whether we’re writing novels or email, we all use text all the time. AppleScript is a great tool for making text-focused work easier and more efficient. For that reason, I get a lot of questions about how to simplify common text tasks. Here are a few of those questions and my answers.

[Read more at Macworld.com, subscribe to the print edition, or get Macworld on your iPad...]

Do you have a scripting problem or a question for the Script Doctor? Send it to scriptdoctor@macworld.com.

Mac Productivity: Quick Scripts and Workflows – Implementing a Spoken Dictionary

A handy feature in Mac OS X is the ability to quickly and easily define words.  In most applications, just Control+click the desired word, and choose Look Up "TheSelectedWord" from the contextual menu to bring up the system-wide dictionary.  Even easier, if you've got a trackpad, just double-tap the word with three fingers to display its definition.  Automator lets you get even more creative.  You can expand these useful dictionary services with one that will read the definition to you.  Here's how you do it... [Read more on the Peachpit blog...]

Mac Productivity: Quick Scripts and Workflows – Creating Quick Notes

It's 9AM and your boss is on the phone.  She's rattling off important info you need for your 9:30AM conference call.  Quick!  You need somewhere to take notes.  Sure, you could use your email client - Mail and Outlbook both include note features.  Or, you could use on of the 50,000 note taking apps you've downloaded.  Better yet, why not use that handy Automator Service workflow you created?  You know, the one that automatically creates RTF notes into a Quick Notes folder, names them with the current date and time, and opens them in TextEdit so you can quickly begin typing?  You recall how easy it was to create.  Here's how you did it... [Read more on the Peachpit blog...]

Mac OS X Lion: The Missing Manual Details Services, Automator, and AppleScript

From the Acknowledgements page...

"Ben Waldie… did a beautiful job updating the Automator/AppleScript material in Chapter 7"
- David Pogue

"Thank you, David, for the opportunity to contribute to such a complete resource on the world's greatest operating system!"
-Ben Waldie

Looking for a great comprehensive book on Mac OS X, which covers everything including powerful built-in automation tools such as Services, Automator, and AppleScript? Look no further. Get your copy today!

Mac OS X Lion: The Missing Manual
David Pogue

With Lion, Apple has unleashed the most innovative version of Mac OS X yet—and once again, David Pogue brings his humor and expertise to the #1 bestselling Mac book. Mac OS X 10.7 completely transforms the Mac user interface with multi-touch gestures borrowed from the iPhone and iPad, and includes more than 250 brand-new features. This book reveals them all with a wealth of insight and detail--and even does a deep dive into iCloud, Apple's wireless, free syncing service for Macs, PCs, iPhones, and iPads.

  • Perfect for newcomers. Get crystal-clear, jargon-free introduction to the Dock, the Mac OS X folder structure, Safari, Mail, and iCloud.
  • Go in-depth. Learn how use key new features such as full-screen apps, Mission Control, the new Mac App Store, Launchpad, Resume, Auto Save, Versions, AirDrop, and more. Are you even more of a power user? Learn to set up a network, make a Lion flash drive, and even learn the basics of Lion's underlying Unix.

There's something new on practically every page of this new edition, and David Pogue brings his celebrated wit and expertise to every one of them. Apple's brought a new cat to town, and Mac OS X Lion: The Missing Manual is the best way to tame it.

About David Pogue

David Pogue is the personal-technology columnist for the New York Times. Each week, he contributes a print column, an online column and an online video. His daily blog, "Pogue's Posts," is the Times's most popular blog. David is also an Emmy award-winning tech correspondent for CBS News and a frequent guest on NPR's "Morning Edition." His trademark comic tech videos appear each Thursday morning on CNBC. With over 3 million books in print, David is one of the world's bestselling how-to authors. He launched his own series of complete, funny computer books called the Missing Manual series, which now includes 60 titles. David graduated summa cum laude from Yale in 1985, with distinction in Music, and he spent ten years conducting and arranging Broadway musicals in New York. He's been profiled on both "48 Hours" and "60 Minutes."

About Ben Waldie

Ben Waldie is president of Automated Workflows, LLC, a company offering AppleScript, Automator, and workflow consulting services to Mac-based businesses. For years, Ben has developed professional automated solutions for companies such as Abercrombie & Fitch, Adobe Systems, Apple Inc., CNN, Microsoft, NASA, PC World, and Time Magazine. Ben is the author of “Automator for Mac OS X: Visual QuickStart Guide" (Peachpit Press) and “AppleScripting the Finder" (Automated Workflows, LLC), has written content for Apple.com, Macworld, MacTech, MacScripter.net, and more, and is the host of the “Mac Automation Made Simple" video podcast series (Peachpit Press). Ben is also the author of an AppleScript training CD for the Virtual Training Company, and is a frequent presenter at Macworld and other industry events.

Creating AppleScript Services in Mac OS X

Services are methods of inter-application communication in Mac OS X. They're ways for applications to share their features with other applications via the Application > Services menu, or through a Services contextual menu.

For example, open a TextEdit document and select some text. Next, choose TextEdit > Services > New Email with Selection. This is a Service provided by the Mail application.

I am often asked how to create AppleScript Services, i.e. scripts that you can run from the Services menu. There are a couple of ways to do this...

1) You can use Automator.

  • Launch Automator
  • Create a new Service workflow

  • Choose the type of content you want the script to process at the top of the workflow
  • Choose the application in which you want the service to be accessible
  • For text workflows, choose if you want the service to replace the selected text with the result of the workflow
  • Search for and insert the Run AppleScript action into the workflow
  • Enter your AppleScript code into the action. If you want the action to process the input, you'll need to write the code to do it. If you want to replace text, then you'll need to return text from the action as output

  • Save the workflow

You're done. You can now run the workflow from the services menu. Download a sample Service workflow that wraps selected text in quotes here.

2) The utility ThisService is a great tool for converting AppleScripts, Perl scripts, Python scripts, or Ruby scripts into Services.

Looking for some useful pre-existing Services to get you started? Visit macosxautomation.com to learn more about Services and download a TON of free Automator Service workflows.

Peachpit Blog Post > Automator Services: Preview Selected URL

12.11.09 - Automator Services: Preview Selected URL.

If you're a user of Mac OS X Mail, then you may know that you can use Quick Look to preview image attachments in a message. To do so, just select an image attachment in a message and press the spacebar, press Command+Y, or click Quick Look at the top of the message. For today's Automator Service workflow tip, we'll take this concept a bit further, by creating a way for you to quickly preview URLs in Mail messages, TextEdit documents, and more, without the need to open Safari. [Read more at Peachpit.com...]

Peachpit Blog Post > Automator Services: Merge Selected PDFs

12.10.09 - Automator Services: Merge Selected PDFs.

Today's Automator Service workflow tip involves something that I do fairly frequently, merging multiple PDF files together. Fortunately, with Automator Service workflows in Snow Leopard, this is now much easier for me than it used to be. [Read more at Peachpit.com...]

Peachpit Blog Post > Automator Services: Apply Filter to Selected Images

12.09.09 - Automator Services: Apply Filter to Selected Images.

If you’ve used Automator before, then you may know that it includes actions for performing basic image manipulation tasks, such as cropping and resizing. Today’s workflow uses one of these built-in actions to apply a filter to selected image files in the Mac OS X Finder. [Read more at Peachpit.com...]

Peachpit Blog Post > Automator Services: Merge Selected Images as PDF

12.08.09 - Automator Services: Merge Selected Images as PDF.

Today's Automator Service workflow tip involves image files. This workflow will receive selected image files in the Finder, and merge them together to form a multi-page PDF document. [Read more at Peachpit.com...]

Peachpit Blog Post > Automator Services: Read Summary of Selected Text

12.07.09 - Automator Services: Read Summary of Selected Text.

Each day this week, I'll be providing tips for creating Service workflows with Automator in Mac OS X 10.6.x Snow Leopard. Today’s workflow will receive selected text in an application, summarize it as a single sentence, and speak the summary aloud for you to hear. [Read more at Peachpit.com...]