Preparing Blog Images with Automator
Automator's the perfect tool for streamlining some of the repetitive things you do on a daily basis. One thing it's great at is doing basic manipulation to lots of image files. Need to resize a bunch of images or convert them from one format to another? No problem, Automator is ready to help. In this post, you'll build an Automator workflow that prepares images for your blog by renaming them sequentially and then scaling them down in size. Don't have a blog? Well, this workflow could also be used for preparing images for insertion into a Word document, or to send in an email. Feel free to adjust to your specific needs.
Building the Workflow
Note: If you have any trouble following along, you can download the complete workflow here.
1. Launch Automator (in your Launchpad or /Applications folder)
2. When the workflow template panel appears, select Service and click Choose. By creating a service, you'll be able to run the workflow on selected files in the Finder.
Creating an Automator Service workflow
3. At the top of the workflow (on the right side of Automator's window), set the Service to receive image files in the Finder. By setting this, the Finder uses its contextual knowledge to only let you run the workflow when you have image files selected.
Setting the workflow to process images in the Finder
4. Search for the New Folder action and add it to the workflow. Enter Scaled for Web into the Name field and leave it set to create the folder on the Desktop. Note that this action has some hidden functionality. First, it knows not to create the folder if one already exists. Second, it receives the selected image files as input when the workflow runs, and it copies them into the newly created folder. This ensures that any manipulations are done later to duplicates, and your original images remain unharmed.
The New Folder action copies your selected images in the Finder into a Scaled for Web folder on the Desktop
5. Find and add the Get Folder Contents action to the workflow. This action retrieves any files in the Scaled for Web folder.
The Get Folder Contents action gets the duplicated image files for processing
6. When Automator processes files, it doesn't always do so in the order you expect. This can be a problem if you want to rename files sequentially. To solve the problem, you'll tell the workflow to sort them. Locate the Sort Finder Items action and drag it to the workflow area. Configure the action to sort the files by name in ascending order.
The Sort Finder Items action makes sure your images are renamed in the proper order
7. Search for the Rename Finder Items action and drag it to the workflow. Automator warns you that this action changes the names of files, and suggests inserting a Copy Finder Items action too, in order to preserve the original names. The first step in your workflow already copies the original images. So, there's no need to copy them a second time. Click Don't Add to tell Automator not to insert the additional Copy Finder Items action.
Automator often warns you when files are modified and suggests working with copies
From the popup menu in the upper left corner of the action, choose Make Sequential (note that the name of the action in your workflow changes to Make Sequential). Set the action to add a number to a new name and enter a dash, followed by the desired name. Configure the other settings to place the number after the name, to separate by a dash, to start numbers at 1, and to make all numbers 2 digits long.
Configure the Rename Finder Items action to sequentially name your images
8. Next, you'll tell Automator to add the date to the beginning of each image's name. Since the Rename Finder Items action doesn't include this option, you'll use a variable. Click Variables at the top of the action library and locate the Today's date variable.
Automator variables let you insert values that are calculated at runtime into your workflows
Drag the Today's date variable to the beginning of the new name field in the Rename Finder Items action. By default, this variable is set to the format M/D/YYYY. The Finder, however, doesn't like slash characters in file names. So, you'll configure the variable to use dashes instead, and to be formatted in YYYY-MM-DD format for better sorting. Click the triangle button on the right side of the variable and choose Edit...
The date variable is editable
Choose Custom format... from the format menu in the Variable Options window that appears.
Custom formatting allows you to specify a precise format for a date variable
Drag year, month, and day components together into the editing field and separate them with dashes. Click the triangle to the right of the month and day components, and set them to appear as two digits. Click Done when you're finished.
Formatting the Today's date variable as YYYY-MM-DD
9. Find the Scale Images action and drag it to the end of the workflow. Again, Automator warns you about modifying your images. And, again, since your workflow is already working with duplicates, you should be safe. Click Don't Add so the Copy Finder Items action isn't inserted too.
Automator really, really, really wants to protect your files. If you get annoyed by these alerts, click the checkbox to prevent future ones from appearing.
Configure the Scale Images action to resize your images To Size (pixels) and enter the desired pixel size. Note that this is on the longest side of the image.
The Scale Images action resizes your blog images
10. Save the workflow as Blog - Scale Images. Automator installs it where it needs to go.
Saving the workflow as a Service makes it accessible in the Finder
Running the Workflow
In the Finder, select a bunch of images and right click to display the contextual menu. Choose Services > Blog - Scale Images to run the workflow.
Your workflow appears in the Finder's contextual menu when you have image files selected
The workflow runs, creates a Scaled for Web folder on your Desktop, copies the images into the folder, renames them sequentially, and scales them the appropriate amount.
The renamed and scaled images are copied into a Scaled for Web folder on your Desktop
Now, with the help of your new Automator service, you can get back to writing, and spend less time editing images. Happy blogging!