A practical guide to using Automator
A practical guide to using Automator
Anonim
A practical guide to using Automator
A practical guide to using Automator
automator-icon
automator-icon

Automator is an incredibly handy Mac OS X program that allows you to automate some of your routine and day-to-day operations. Unfortunately, most new Mac users don't even know this tool exists. Therefore, today I will try to fix this and, with the help of visual examples, show the basic principles of creating mini-programs, which are called "processes" (workflow).

Batch rename images

We will start, perhaps, with a rather simple task of group renaming of images according to a certain mask containing the file name, its number and the current date. If there are several such files, then you can rename them manually, but if there are a large number of files, I recommend using the Automator services.

To launch the utility, you just need to either find its icon at the top of the Applications directory, or use your favorite launcher to launch applications / system Spotlight. And after a few seconds, an application window will appear in front of us, as well as a list of available templates:

  • A “Process” is the simplest sequence of actions that can be started directly from Automator.
  • The "Program" is a stand-alone process and can be saved as a regular Mac OS X application with the extension

    *.app

  • .
  • A "service" is a context dependent process that can be used throughout the system or in individual applications.
  • The "folder action" is launched only for the specified folder and is initialized by the objects added to it.
  • "Print plugins" are used to extend the capabilities of the print dialog.
  • ICal Reminders are processes that are triggered by events added to iCal.
  • Finally, the "Image Capture Plugin" can be used in an appropriate application to process photos downloaded from a camera.
automator-01
automator-01

In our case, select "Folder Action" - and a window will appear in front of us, divided into 2 areas. The left half contains the Library (a list of available actions and variables), and the right half contains the workflow window, into which you can drag items from the Library.

Using the option located at the top of the process window (right below the toolbar), you need to select a folder. For her, our actions will be performed:

automator-02
automator-02

Everything that we may need to solve the problem is located in the "Files and folders" category. First you need to find and drag an action called "Rename Finder Objects" into the workflow window. Since Automator changes their names, we will be prompted to automatically add another action to save the original files to a different folder (I decided not to save copies, but that doesn't mean you need to do the same).

Now, in the very first drop-down list of our action, you need to select the "Make sequential" item and configure the format of the new name at your discretion. This is easy enough, as there is an example at the bottom of the activity.

To add the current date to the file name, you need to drag the Rename Finder Items action to the workflow window again. Only this time, instead of "Make sequential", select the "Add date or time" list item (more precisely, it is selected automatically) and set the parameters as you wish:

automator-03
automator-03

You can simply check the work of the process: save it and drag the group of files into the folder indicated at the very beginning. After a while - it depends on the size and number of files - their names will be automatically changed. See how easy it is?

Batch resizing images

We complicate the task. Let's say we have a large number of images (photographs) that need to be reduced. To solve this problem, we need to select the "Program" template.

automator-04
automator-04

However, before rushing to solve the problem "head-on", I propose to draw up a sequence of necessary actions. For example, to begin with, you should prompt the user to select the photos that we want to resize. In addition, it is advisable to work not with the originals of the files, but with their copies, so that there is always an opportunity to try new settings for our process. And we will copy the thumbnails into a separate directory.

Now you can proceed to the formation of our mini-program. First, you need to find and drag the "Request Finder Items" action in the "Files and Folders" category (or through the search bar) into the workflow window. There you can specify the window title text, start folder and data type. Don't forget to set the checkbox for multiple selection.

To work with copies of files, I suggest finding the action "Copy Finder Items" in the Library, specifying the destination directory. The next step is in the Photo category and is called Zoom Image. In the settings, you can specify the size of the resulting image in pixels or percent.

By the way, there are three tabs in the bottom pane of each action: Results, Options, and Description. Therefore, if you want Automator to prompt you to specify the required image size each time when performing this action, select the "Show action in progress" checkbox in the Parameters tab. files to rename).

If you notice, a triangular arrow comes out of each action, which represents the result of its work. These results are then used as input parameters in the next step.

And one more trick: by selecting the "Show action in progress" checkbox, the "Show only selected objects" option will become active. Thus, you will be able to display not the entire window with the action, but only some elements. For example, a field for specifying the required size.

And at the end of the process, we need to transfer the thumbnail image to a new directory. For this we need the action "New folder" from the category "Files and folders".

automator-05
automator-05

The saved program will behave exactly like any other application on the system.

Opening certain web pages when starting the browser

Almost every day I launch Safari and start working with the same web pages. So why not create an app that does this automatically?

We need an Application template and two actions located in the Internet category:

  • "Get highlighted URLs", in the settings of which we indicate our favorite web pages;
  • and the action "Display web pages" to open them in the default browser.
automator-06
automator-06

Extract text from PDF

This is a fairly simple but handy script for Automator and can sometimes save you time. It will allow you to extract text from a PDF document (of course, such a document should contain just text, not scanned pictures) and save it to a separate file with or without formatting.

To solve the problem, we need only one action with the same name, "Extract PDF Text", located in the "PDF Files" category. Drag it to the workflow window and adjust the options as you like:

automator-07
automator-07

Note that in this process we did not specify the action "Request Finder Items", so once launched, you can drag any PDF file to be processed directly onto our application icon in the Dock. This file will serve as an input parameter for the process.

Save the contents of the clipboard to a text file

We continue to get acquainted with different Automator templates, and in this process I propose to create a service that will save the contents of the clipboard to the text file we specified. The required template is called "Service". She will not teach any initial data, but will "act according to the situation."Therefore, it will not have input data, which is required to be specified in the drop-down list above the workflow window.

Next, in the workspace, copy the action "Get clipboard contents" from the "Service utilities" category (it has no settings) and the "New text file" action from the "Text" category.

automator-08
automator-08

Our service needs to be given a human name so that we can easily find it in the "Services" menu of any application …

automator-09
automator-09

… and assign it, if required, a keyboard shortcut in the System Preferences application.

automator-10
automator-10

And if you replace the action "New Text File" with "Text to Audio File", then as a result of the process you will receive an audio track with the contents of the clipboard, recorded using the built-in Mac OS X text-to-speech function.

automator-11
automator-11

In general, this function was designed specifically for people with disabilities, but if desired, it can also be used for entertainment purposes.

Simple automatic backups

As we continue to complicate things, I now propose to create a simple backup system that will be triggered when a certain event occurs in iCal. To do this, we will use its ability as a reminder of the event to launch a specific application or file.

automator-12
automator-12

In Automator, select a new type of template - "iCal Reminder", and then drag three actions from the "Files and Folders" category to the workflow window:

  • "Get specified Finder objects" (select the desired folder for backup using the Add button).
  • "Retrieve contents of folders" with the option "Repeat for each found subfolder" selected.
  • And "Copy Finder Items" (it needs to specify the destination directory and allow overwriting existing files).
automator-13
automator-13

As soon as you save the process, iCal will start and an event with the name of your process will be automatically added for the near future. You can change this event at your discretion, as well as create a completely new, independent event, indicating the need to launch our program in the reminder section:

automator-14
automator-14

Quit all applications

Sometimes it is required to terminate all running applications that interfere with work or have occupied almost all the free resources of the computer. In this case, you can use a special utility like Blitz, one of the tips for concentrating on Mac OS X, or start from scratch by closing all applications in one fell swoop.

This workflow requires just one programmed action. And this action is called similarly - "End all programs" (it is located in the "Utilities" category). You can also add some applications to exceptions. In "difficult times", all you have to do is launch our gadget, wait a while, and enjoy the Mac's performance again.

automator-15
automator-15

That's all for today! I hope that this article will help you not only understand the wonderful and useful Automator tool, but will also greatly simplify some of the routine operations. Do not be afraid to experiment, because if you wish, you can take as a basis any of the examples discussed above and change them as you see fit.

Recommended: