Posts for tag: Automator 3

How to apply one picture to all desktops on OSX 10.8 using Automator

So you have several desktops set up in Mission Control and you have assigned various apps to each desktop. Now when you want to change your desktop picture you open up System preferences, navigate to the Desktop & Screensaver panel and apply a new picture. At this point OSX 10.8* changes only the picture on the currently active desktop so, if you want to change all desktops to the same picture you have to swap to each desktop and change it manually. Fine if you only have 2 or 3, but if you have many desktops how can you change them all at the same time?

*this probably applies to OSX 10.7 as well - I don't know, as I jumped straight from OSX 10.6 to OSX 10.8.

Automator icon from Mountain Lion

This is where Automator comes in. Automator allows you to script many tedious tasks on you mac (see my previous posts on using Automator), in this case we will be selecting a new picture and then rewriting the desktop preferences file to use only that selected picture. The finished Automator script will be a ”Service“. It will be available in the Finder under Finder -> Services -> Change All Desktop Picutres…

1 Open Automator

Automator is in the Applications folder. Open it and select “Service” as the document type.

2 Start building your script

At the top of the workflow pane (the right-hand column where it says “Drag actions or files here to build your workflow.”) you will see “Service receives selected text in any application” where ‘text’ and ‘any application’ are select boxes. Change the select boxes to read “Service receives no input in Finder”.

3 Adding the first action “Ask for Finder Items”

The Automator Library

From the Library column on the left of the Automator window select “Files & Folders” then from the second column double-click on “Ask for Finder Items” (or drag it in to the workflow).

4 Configuring the “Ask for finder Items” action.

First, change the “prompt” message to “Choose a desktop picture:”, then Select “Start at:” and navigate to where you keep your desktop pictures (I keep all mine in the default: /Library/Desktop Pictures/ folder). Finally make sure that “Allow Multiple Selection” is unchecked.

5 Adding the “Run Shell Script” action

Select “Utilities” from the library and then double-click or drag the “Run Shell Script” action to add it to your workflow.

6 Configuring the “Run Shell Script” action

Once you've added the action, make sure that the first two select boxes are set to:


Shell: /bin/bash
Pass input: to stdin

Now in the text area (Where it says cat), delete cat and replace it with the following shell script:


read -e PICTURE;
 
function set_all_desktops
{
defaults write com.apple.desktop Background "{default = {ImageFilePath='$PICTURE'; };}";
killall Dock
}

set_all_desktops

the finished Automator workflow

7 Saving and running the new Service

The finished workflow in action

Choose File -> Save and call it “Change All Desktop Pictures…” and you're done. Now to run your new service switch to the Finder and choose Finder -> Services -> “Change All Desktop Pictures…”. In the dialog that opens simply select the new picture and click on “Choose” and all your desktops will be updated.

The Finder services menu

In this example we have built the script as a Finder Service, however you could also build it as an Application which could then be put in the dock. In fact I already have and you can download it from the Automator Workflows section of my Software page.

Batch convert images with Automator on Mac

automator

Following on from my post on FTPing images using only a keyboard shortcut, here's a quick post to show you how to quickly batch convert images from one format to another...

1) First fire up Automator, and select 'Service' as your chosen workflow template, then as before change the two drop-down menus to read 'Service receives selected image files in Finder'.

2) In the far left-hand 'Library' column select the 'Photos' Library, then from the next column locate the 'Change Type on Images' action and drag it across in to the main window. You will be asked whether you want to convert the original image or a copy. If you choose to convert a copy, Automator will add another action to your workflow (Copy Finder Items). However, for now I will continue as if you have selected to work on the original.

3) You can now see the action added to your workflow. Located at the bottom of the action window are 3 options - 'Results', 'Options' and 'Description'. Click on 'Options' and check the 'Show this action when the workflow runs' checkbox.

workflow

Basically what this does is give you the option when you run your workflow to select what kind of file type to convert to. If you don't check it, the workflow will run and convert the image to the file type selected in action when the workflow is saved.

4) One last thing to do — if you think you will mostly be converting images to .png, set the 'To Type' menu to .png (or whatever you prefer).

5) Now save it and give it a name. I've called mine 'Convert images'. If you want to set up a keyboard shortcut look at my post on FTPing images to see how it's done.

Services menu

And that's it — simply select an image or multiple images in the Finder and then hit your shortcut or select your new workflow by right-clicking on them — a small dialog box will appear — choose the file type, click continue and your files will be converted!

It should be easy from here on to create some more image processing workflows of your own...

FTP files quickly on a Mac using Automator

automator

Wouldn't it be great if you could upload an image to your site just by clicking on it instead of having to open an FTP client, connect to your server, browse for the image etc...?

Well, if you are on a Mac you can, by creating an Automator action to do it for you, and here's how.

1 First you will need to download the Upload to FTP action by Peter Dekkers, you can get it here: http://www.apple.com/downloads/macosx/automator/uploadtoftp.html

Once the Disk image has mounted, double click on the Install Upload to FTP package and follow the install instructions.

2 Now, open Automator (it's in the Applications folder). You will be asked to choose a template for your workflow. Choose 'Service' and click 'Choose'. At the top of the screen you will see two select menus. Change the selections until they read: Service receives selected image files in Finder.

automator options

3 Now, on the left side of the automator window you will see the Library containing actions for various applications. Upload to FTP has been installed in to 'Other'. Click on 'Other', and Upload to FTP will appear in the column to the right. Click on it and drag it in to the main Automator window (Where it says 'Drag actions of files here to build your workflow').

4 The options for Upload to FTP are pretty self explainitory, if you're unsure copy and paste the details from your FTP client. At bare minimum you will need to enter:

FTP options
  • Server
  • Username
  • Password
  • Directory
  • Port

5 Once you're done select Save from the File Menu and name the action (I named mine 'Upload blog image'). The action is now fully working, try it out — highlight an image in the Finder then 'right click' or 'control click'* on it and from the 'Services' menu choose your action. The file will automatically be uploaded to the chosen folder on your server!

You can make the process even quicker by giving the action a shortcut key. To do this, open System Preferences and choose the 'Keyboard' preference pane. Select the 'Keyboard Shortcuts' tab, then select 'Services' from the left column. Click the '+' icon to add a new shortcut, then choose 'Finder', add the exact name of your action, and enter a shortcut (I chose 'Control-Option-CMD-U').

Now, all you need to do is highlight an image, hit the shortcut and it's done!

You can also add other actions to your workflow — for instance you could resize the images and then FTP them. The images for this article were uploaded in this way.

* it depends on what kind mouse you have

HOME