Monday, May 20, 2013

5 Automator workflows everyone should have

Automator (software)
Automator (software) (Photo credit: Wikipedia)

macworld.com


5 Automator workflows everyone should have


I meet a lot of people with Automator anxiety: they think using OS X’s built-in workflow-maker is a lot more complex than it really is. The truth is that Automator workflows are (a) pretty simple to assemble and (b) great for simple but repetitive tasks that you do all the time anyway.


To show you what I mean here are five workflows that I think pretty much every Mac user should have. They do things we all need to do: Wrap text in quotation marks, for example, or count the number of words in a selection of text. There might be other ways of doing the same things, but Automator is built into your Mac and you can implement them yourself for free in a couple of minutes.

Wrap text in quotes


This one works with selected text to wrap it in quotation marks.


To start, create a new Automator Service workflow and configure its header area to process selected text in any application. Click the Output Replaces Selected Text checkbox so the result of the workflow—the wrapped text—will be inserted in place of your selection.


Although Automator includes a number of actions for working with text, it doesn’t have one for adding a prefix or a suffix. As a workaround, you’ll need to use AppleScript for this. So, add the Run AppleScript action to the workflow, and copy-and-paste in the following script, which simply adds quotation marks around any text input it receives:



on run {input, parameters}
     return "\"" & (input as string) & "\""
 end run




Save the finished workflow as Text > Wrap in Quotes and you’re done.


The next time you’re ready to wrap some text in quotation marks, just Control- or right-click the selection and choose Text > Wrap in Quotes. (You could also choose the workflow from the Application > Services menu.)

Count words of selected text


Another one for working with selected text, this one gives you a quick word count.


Create a new Automator Service workflow and set it to process selected text in any application. Leave the Output Replaces Selected Text checkbox unchecked.


Automator doesn’t have any built-in actions for counting words. So, again, you’ll have to add the Run AppleScript action to the workflow, and enter the following:

on run {input, parameters}
     set theWordCount to count words of (input as string)
     display dialog (theWordCount & " words in the selected text." as string)
 end run
Save the workflow as Text > Display Word Count. Next time you want to know the length of some text, just select it and run the workflow from the Services menu.

Create subfolder


Although it would be super useful, OS X still lacks a handy Add Subfolder command in the Finder. Sure, you can open a folder first, and then create another folder inside of it, but that’s one more step than necessary.

Create a new Automator Service workflow and set it to process folders in Finder.

Find the Set Value of Variable action and add it to the workflow. Then, from its popup menu, create a new variable and name it Folder.

After that, add the New Folder action to the workflow. Enter a name of Subfolder or whatever else you prefer. Drag the folder variable from the Variable area at the bottom of the workflow to the Where popup. Finally, with the action selected, choose Action > Ignore Input from the menu bar. This is important because the New Folder action copies anything it receives as input into the new folder, and you don’t want this to happen. By setting the action to ignore its input, you bypass this behavior.

Save the workflow as Folder > Create Subfolder. The workflow should now appear under Services in the Finder’s contextual menu when you Control or right-click on a folder. Just select a folder and then the service.

Add date to files


This one adds a current date prefix to the names of any selected files or folders.

Create a new Automator Service workflow and set it to process files or folders in Finder. Find the Rename Finder Items action and drag it to the workflow. If Automator prompts you to insert a Copy Finder Items action first to preserve your originals, click Don’t Add; you’re just adding a prefix to the names of the files, not deleting them or anything serious like that.

Configure the action to Add Date or Time. Then set the Date/Time popup to Current, the Format popup to Year Month Day, the Where popup to Before name, the first Separator popup to Dash, the second Separator popup to Space, and click the Use Leading Zeros checkbox. While all of this sounds kind of complicated, it’s really just telling Automator you want the date prefix in YYYY-MM-DD format.

Lastly, save the workflow as Files and Folder > Add Date Prefix. Your workflow now shows up in the Finder’s Services menu when you Control- or right-click on something. Select a file or folder, then select the service, and the date will be prepended.

Toggle hidden files


Sometimes it helps to see hidden system files; this one toggles their visibility on and off.

Start by creating a new Automator Application workflow. Automator doesn’t have an action for toggling on and off the visibility of hidden files, so again you’ll need to use AppleScript to do it. Actually, this AppleScript really just triggers a bunch of Unix commands to update the Finder’s preferences to show hidden files and then relaunch the Finder. Add the Run AppleScript action to your workflow, and enter the following:

if {"OFF", "FALSE"} contains (do shell script "defaults read com.apple.finder AppleShowAllFiles") then
     set theValue to "TRUE"
 else
     set theValue to "FALSE"
 end if
 do shell script ("defaults write com.apple.finder AppleShowAllFiles " & theValue) as string
 do shell script "killall Finder"
(When you copy and paste, make sure that the first line, beginning "if" and ending "then", and the sixth, beginning "do" and ending "as string" are each a single line, with no hard returns in the middle.) Just save the workflow as Finder > Toggle Hidden Files. That done, if you double-click that app, your Finder will disappear for a second, then reappear with hidden files showing or hidden (depending on their state before you launched the app). (And be careful with those hidden files: They usually do important stuff, and deleting or renaming them could get you into trouble.)

Have any trouble following along, or get stuck somewhere? Don’t worry, you can download an archive containing the complete workflow .


Source: macworld.com

Enhanced by Zemanta

Thursday, May 9, 2013

Watching What You Want When You Want To With The Mac Mini


macworld.com

  • May 9, 2013
Trot back to the 16th century and corner famed prognosticating monk Nostradamus, and it’s quite likely that when posed the question: “Will those living in the year 2013 be able to call up any media programming they like from a single box?” he’d respond with an enthusiastic “Mais oui!”

Sadly, we know only too well where this one sits in the cleric’s win/loss column. Progress has been made, via cable and satellite services that deliver a trillion channels plus on-demand programming, as well as set-top boxes that have access to online music and video services.

But the ultimate goal—watching exactly what you want to watch when you want to watch it—remains elusive.

 In search of a solution, some people have turned to the most powerful media device in their home—their computer.  Not only can it play locally stored music, video, and slideshows, but it can also bring you any media found on the Internet, including streaming TV programming, movies, and music.

But sitting in front of a computer monitor—regardless of its resolution—can be limiting. It makes for a less-than-satisfying group-viewing experience, and it’s hard to shake the feeling that you’re, well, sitting in front of a computer. What many of us want is a device as intelligent as a computer but one that’s at home in the living room, attached to a big-screen TV.

Turns out that Apple produces a device fitting that exact bill: the Mac mini. Small, not obscenely expensive, and capable of accessing media locally as well as online, the Mac mini has a lot going for it. But is it the perfect solution for those anxious to cut the media cord? I spent a month with one to find out.

About the box

I chose the $599 base-model Mac mini for my media experiment, largely based on its price and performance. That mini includes a 2.5 GHz dual-core Intel Core i5 processor, 4GB of memory, a 500GB hard drive, and the Intel HD Graphics 4000 chipset built into the motherboard.

For another $200 you can purchase a Mac mini with a i7 processor and a 1TB hard drive. I chose to save that $200 because the base-model’s processor is fast enough for a media server, and because, while storage is important for this kind of use, an external hard drive offers more space for less money.

About the box

I chose the $599 base-model Mac mini for my media experiment, largely based on its price and performance. That mini includes a 2.5 GHz dual-core Intel Core i5 processor, 4GB of memory, a 500GB hard drive, and the Intel HD Graphics 4000 chipset built into the motherboard. For another $200 you can purchase a Mac mini with a i7 processor and a 1TB hard drive. I chose to save that $200 because the base-model’s processor is fast enough for a media server, and because, while storage is important for this kind of use, an external hard drive offers more space for less money.