AppleScripts for Marking Messages as Read in Mac Mail

At the request of MacSparky, I've put together a few AppleScirpts for Mac Mail users, to mark messages as unread...

Script 1: Mail • Mark All Inbox Messages Read

tell application "Mail"
     set read status of every message of inbox to true
end tell

Script 2: Mail • Mark All Messages Read

display alert "Please note!" message "This script may take a while if you have a ton of mailboxes. Do you want to continue?" buttons {"Cancel", "Yes"} cancel button "Cancel"

with timeout of  600 seconds
     tell application "Mail"
          set read status of every message of inbox where its read status = false to true
          set read status of every message of every ¬
               mailbox where its read status = false to true
          set read status of every message of every mailbox ¬
               of every account where its read status = false to true
     end tell
end timeout

Script 3: Mail • Mark Selected Mailbox Messages Read

display alert "Please note!" message "This script may take a while if you have a lot of mailboxes selected. Do you want to continue?" buttons {"Cancel", "Yes"} cancel button "Cancel"

set processSubMailboxes to (button returned of (display alert "Would you like to scan all submailboxes too?" message "Again, if you have a lot of selected mailboxes and submailboxes, this may take a while." buttons {"Yes", "No"})) = "Yes"

tell application "Mail"
     tell front message viewer
          set theSelectedMailboxes to selected mailboxes
          repeat with a from 1 to length of theSelectedMailboxes
               set theCurrentMailbox to item a of theSelectedMailboxes
               processMailbox(theCurrentMailbox, processSubMailboxes) of me
          end repeat
     end tell
end tell

on processMailbox(theMailbox, processSubMailboxes)
     tell application "Mail"
          if processSubMailboxes = true then
               set theSubMailboxes to every mailbox of theMailbox
               repeat with a from 1 to length of theSubMailboxes
                    set theCurrentSubMailbox to item a of theSubMailboxes
                    processMailbox(theCurrentSubMailbox, processSubMailboxes) of me
               end repeat
          end if
          set read status of every message of theMailbox to true
     end tell
end processMailbox

Usage

You can download these scripts here.

You can quickly and easily run them from the system-wide AppleScript menu.  This menu is not enabled by default.  To enable it and install the scripts...

  1. Launch AppleScript Editor in /Applications/Utilities
  2. Select AppleScript Editor > Preferences from the menu bar
  3. Under General, click the Show Script Menu in the Menu Bar checkbox
  4. Bring Mail to the front
  5. From the script menu, choose Open Scripts Folder > Open Mail Scripts Folder
  6. Copy the scripts into the folder.  They will now be available from the script menu when you're working in Mail

Enjoy!

-Ben

What not to do in Mac Mail

Here's a handy data loss prevention tip.  With a Mail message selected, do not press either of the secret undocumented keyboard shortcuts Option+Control+H or  Command+Option+Control+H.  That is, unless you want your selected message irretrievably deleted.  Not moved to the trash.  Deleted.  Permanently.

Tested in Mac OS X 10.7.3. Bug report filed.

Note: If you're backing your Mac up with Time Machine, as you should be, then you may be able to restore the vaporized message.

10 Mac OS X Productivity Tips for Open and Save Dialogs

They're open and save dialogs. You navigate to a file or folder. You select it.  You enter a file name when saving.  You click Open or Save.  How much more efficient can you get? Well, here are 10 things most Mac users probably don't know...

Tip 1: Drag and drop a file or a folder right from the Finder into the open or save dialog to quickly select it.  If you do this in a save dialog with a file, then the file's name is automatically entered as the save name.

Tip 2: With a folder or file selected in the dialog, press Command+R to bring the Finder to the front and reveal the item.

Tip 3: To manually navigate to a folder, press Command+Shift+G (or / or ~).  Enter the desired path.  As you type it in, you can press tab to auto-complete folder names.

Tip 4: To see hidden files and folders, press Command+Shift+Period (>).

Tip 5: To quickly navigate to:

  • The Desktop - Press Command+D
  • The Documents Folder - Press Command+Shift+O
  • The Downloads Folder - Press Command+Shift+L
  • The Applications Folder- Press Command+Shift+A
  • The Home Folder - Press Command+Shift+H

Hint: The other navigation keyboard shortcuts in the Finder's Go menu should work here too.

Tip 6: To create a new folder, press Command+Shift+N.

Tip 7: To navigate up one level, press Command+Shift+Up Arrow Key

Tip 8: To choose an image, audio track, or movie, click Media in the sidebar.

Tip 9: To move a file or folder displayed in an open or save dialog to another folder, open the target folder in the Finder.  Then, drag the item from the open or save dialog into the opened folder window in the Finder.

Tip 10: With a file or folder selected, press Command+I to bring the Finder to the front and display the Get Info window for the item.

So, there you have it. Small tips that will save you a few precious seconds here and there and make you more productive.  Every second counts, right?

Macworld | iWorld 2012 Favorite Find: olloclip

More and more, my iPhone is becoming my camera of choice.  It takes great photos, and I always have it with me.  This year, at Macworld | iWorld, I was excited to stumble upon the olloclip.  It's a 3-in-1 lens that fits snuggly over your existing iPhone lens.  Included lenses are fisheye, wide-angle, and macro.  I have to say, I love this lens, and highly recommend it for anyone who wants to do more with iPhone photography.  It'll set you back about $70, but it's such a great little accessory, to me, it's well worth the price.

For anyone considering it, here are some observations…

  • The olloclip is tiny.  It will easily fit in your pocket.
  • It only works with the main iPhone camera (the one on the back of the phone), not the one that faces you.
  • You access the macro lens by unscrewing the wide-angle lens.  To use the macro lens, you need to get in very close, within about 1/2".
  • The fisheye lens has an extensive range, so you'll need to grip your iPhone more on the sides if you want to prevent your fingers from being visible along the edges of the photos.
  • The olloclip is a tight squeeze.  You'll have to remove your phone from its case to use it.  And, if you have a screen protector, it may push it out of the way if you aren't careful.
  •  The olloclip is designed for the iPhone 4/4S.  If Apple releases a new form factor iPhone 5, you'll probably need to purchase a new olloclip, assuming they release an updated version.
  • The olloclip comes with a small microfiber bag, which doubles as a lens cleaner.

In short, I concur with Stephen Hackett's Three-Word Review of the olloclip… Buy it now!

-Ben

olloclip Gallery:

Now Available: New Mac Automation Made Simple Videos!

Peachpit has bundled a new series of my Mac Automation Made Simple videos on Automator.  They're now available for purchase as DRM-Free downloads, so you can play them on your Mac, iPhone, or iPad.  Topics in this 8-part series include:

  • Automate generating job folders - If you use job folders for multiple projects to keep organized, learn how to save time and reduce errors by building workflows in Automator to create job folders consistently and quickly. You'll also learn the basics of actions and variables in Automator.
  • Batch-create folders from an Excel list - If your workflow ever requires you to create a large number of folders or sets of subfolders with specific naming conventions, Excel and Automator can work together to eliminate the manual creation of folders. By using the powerful features in Excel to build lists of file names in large numbers and use Automator to process those lists into hundreds of folders in minutes.
  • Display Growl notifications for new content - File sharing over a network is great for larger files that you wouldn't send via email, but how can you be sure that you're always notified when a new file lands in your folder? Learn how to team Automator with the popular notification software Growl to build a great workflow that eliminates the need for you to get an email or phone call notifying you of new files.
  • Schedule backups via a network - Do you manually back up your Mac to a server? If so, you've probably had to set up calendar reminders and run through the process on a regular basis or risk losing your data. In this lesson, learn how to make that process automatic and painless with Automator and iCal.
  • Share files via Dropbox - Take the powerful PDF tools offered in OS X a step further by building your own Print Plugin with Automator. You'll learn how to set up a Print Plugin that automatically posts any document you print to PDF to the online file sharing tool Dropbox. You'll also learn the basics of setting up actions to rename files to be friendly for upload tools by removing offending characters.
  • Batch-convert image files to PDF - If you've ever had the daunting task of scanning a book or a box of images with a flat bed scanner, you know that it isn't easy to combine all those files into a single PDF without some heavy-hitting applications like Photoshop and Acrobat Pro. But what if you don't have those applications or are just looking for an easier way? Learn how to set up a quick and easy way to combine multiple images into a single PDF without the hassle.
  • Batch-process images for iPhoto - If you're like most people with a smart phone, an amature photographer or have a large photo digitizing project on your plate, you'll import, manipulate and save hundreds to thousands of images a year. In this lesson, you'll learn how to unleash the power of Automator and free third-party tool to streamline your workflow and make importing images to your iPhoto library a snap.
  • Batch-process multiple InDesign files to PDF - Exporting multiple InDesign files to PDF can be as quick and easy as dragging and dropping your files. You'll learn how to create a drag-and-drop application with AppleScript and Automator that opens, exports, names, and saves PDFs from InDesign. You'll be able to use the same custom application for both InDesign CS4 and CS5.

Sold as a set, or individually, you can find them on Peachpit's website.

Mac Power Users Podcast Episode 070 – Working with Automator

I recently spoke with Katie Floyd and David Sparks about the automation capabilities in Mac OS X for episode 070 of the Mac Power Users podcast.  Topics included getting started with Automator, troubleshooting Automator workflows, Services, and differences between AppleScript and Automator.  Check it out on the Mac Power Users website or in iTunes!

MacIT | Macworld | iWorld Discounts

Planning to attend MacIT | Macworld | iWorld 2012?  Here are some discount codes you can use when registering...

  • Save $25 on my Mac OS X Automation Workshop using priority code CCU18842
  • Save $50 on an All Access Pass or MacIT Conference Pass using priority code BTR34210
  • Get a free exhibit hall pass (limited to the first 100 applicants) or save $15 on an iFan Pass using priority code BSU47117
You can register here.  Hope to see you there!
-Ben Waldie

Automation and Productivity Sessions at Macworld | iWorld 2012

Well, it's that time of year again. Folks are gearing up for Macworld San Francisco. This year, the conference has been renamed Macworld | iWorld, and a secondary conference has been added specifically for MacIT. As usual, I'll be there, presenting a number of sessions on automation and productivity. Here's the list of my sessions...


MacIT Sessions

[More info about MacIT]


Macworld | iWorld Sessions

If you're planning to attend my workshop, you can save $25 using priority code CCU18842 and registering here.

[More info about Macworld | iWorld]

Going to be there too? If so, be sure to find me and introduce yourself.

Hope to see you there.

-Ben Waldie

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.

File and Folder Automator Actions Released in the Mac App Store

I'm still working hard on updated Automator action packs. I'm pleased to announce that my File and Folder Automator Action Pack, which includes 21 actions for interacting with files and folders in the Finder has been released in the Mac App Store. It can be found here.

-Ben