A practical guide to using Automator
Makradar Technologies / / December 19, 2019
Automator - it's incredibly easy to use program from the Mac OS X, which allows you to automate some routine and daily operations. Unfortunately, the majority of new Mac users are not even aware of the existence of this tool. So today I will try to fix it and with the help of illustrative examples show the basic principles of the creation of mini-programs, which are called "processes» (workflow).
Multi-rename images
We begin, perhaps, with a rather simple task of batch renaming of images according to a predetermined mask, containing the file name, number and the current date. If there are multiple files, you can rename them manually, but with a large number of files I recommend using Automator services.
To start the utility, it is sufficient to either find its icon at the top of the program directory (Applications), or use your favorite launcher to run an application / system Spotlight. And after a few seconds, the application window appears in front of us, and a list of available templates:
- The "process" - this is a simple sequence of actions that can be run directly from the Automator.
- "Program" is an autonomous process and can be saved as a Mac OS X application with the usual extension
* .app
. - "Service" - a process that depends on the context, can be used in the entire system or specific applications.
- "Folder Action" runs only in the specified folder, and it is initialized with the added objects to it.
- "Print Plug-ins" are used to empower print dialog.
- "Reminders iCal» - is processes that are triggered by events, added to iCal.
- Finally, "image pickup plugin" may be used in the appropriate application for processing images downloaded from the camera.
In this case, select "Folder Action" - and a window will appear in front of us, divided into 2 areas. The left half is a library (available actions and variables), and the right - the workflow window where you can drag items from the Library.
With the help of the options at the top of the process window (just below the toolbar), you need to choose a folder. For her, and will run our actions:
All that can, we need to solve the problem is in the category "All files and folders." To get started you want to find and drag the window to the workflow action called "Rename objects Finder». Since Automator change their names, we will be prompted to automatically add another action, allowing keep the original file to another folder (I decided not to keep copies, but that does not mean that you need to do exactly also).
Now, in the first drop-down list of our action is necessary to select the "Make consistent" and set the format of the new name at its discretion. Make it easy enough, as in the lower part of the action is an example.
To add the name of the current date files require more time to drag the action "Rename Finder items" in the workflow window. Only this time, instead of "Make consistent" select list item "Add a date or time" (more precisely, it is selected automatically) and set the parameters of their own accord:
Check the work process can be simple: keep it and drag a group of files to a specified folder in the very beginning. After some time - it depends on the size and number of files - their names will be automatically changed. See how simple?
Grupovoe image resizing
Complicates the task. Suppose we have a large number of images (photographs) to be reduced. To solve the puzzles, we need to choose a template "Program".
However, before you rush to solve the problem "head-on", I propose to make a succession of actions. For example, should first offer the user a selection of photos, the size of which we want to change. In addition, it is desirable to not work with the original file, but with their counterparts, to have always had the opportunity to try new settings for our process. A thumbnail images, we will be copied to a separate directory.
Now we can proceed to the formation of our mini-program. First you have to find and drag in the "Ask the Finder objects' workflow window effect in the category" Files and Folders "(or through the search bar). There you can specify the text of the window title, the initial location and the type of data. Do not forget to set the checkbox for multiple selection.
To work with copies of files, I propose to find in bibilioteka action "Copy objects Finder», specifying the destination directory. The next step is in the category of "Photo" and is called "zoom". In the settings you can specify the size of the output image in pixels or percentages.
By the way, in the bottom panel of each action, there are three tabs: Results, parameters and description. So if you want to every time Automator will ask you the necessary size of the image when doing this, select the checkbox "Show action in the process of execution "in Vladko parameters (if desired, with this option can extend the previous process to define a particular file name for rename).
If you notice, every action comes from the triangular arrow, which is the result of his work. These results are then used in the next step as input.
Another trick: by selecting the checkbox "Show action in progress" will be active the option "Show only selected objects". Thus you can not display the entire window to the action, but only some of the elements. For example, a field to specify the desired size.
And at the end of the process we need to move the thumbnail to a new location. To do this we will need the action "New Folder" from the category "Files and Folders".
The stored program will behave in exactly the same way as any other application on the system.
Open a certain web page when you open your browser
Almost every day I run Safari and start working with the same web pages. So why not create an app that will do this automatically?
We will need the template "Application" and two actions that are in the "Internet" category:
- "Get a dedicated URL», in settings where we point our favorite web pages;
- and the action "Show Web page" to open them in the default browser.
Extract text from PDF
It's pretty simple, but comfortable scenario for Automator, allowing sometimes to save time. It allows you to extract text from the PDF-document (of course, in such an instrument should be just text, not scanned images) and save it as a separate file with or without formatting.
To solve the problem, we need only one action with the same name, "Extract the text of a PDF", located in the «PDF-files" category. Drag it to the workflow window, and adjust the settings as required:
Note that in this process we have not specified the action "request object Finder», so after launch you can drag and drop any PDF-File to be processed directly on the icon of our application in Dock. This file, and will serve as input parameters for the process.
Save the contents of the clipboard as a text file
We continue to get acquainted with different templates, Automator, and in the process, I propose to create a service that will save the contents of the clipboard to the specified contact text file. The required pattern is called - "Service". It will not teach any initial data, and will "act according to circumstances." Therefore, the input data it will not have that, and you want to specify in the drop-down menu above the workflow.
Further, the workspace copy the action "Get the contents of the clipboard" from the category "Service utilities" (he does not have the settings) and the action "New text file" from the category "Text".
Our service should be given the human name, so we can easily find it in the menu "Services" any application ...
... and then give it, unless of course need a keyboard shortcut in the application System Preferences.
And if you replace the action of the "New text file" on the "Text to Audio File", then as a result of the process, you get audio track with the contents of the clipboard recorded using the built-in Mac OS X text-to- speech.
Generally, this function has been specifically designed for people with disabilities, but if desired it can also be used for entertainment purposes.
Simple automatic backups
We continue to complicate the task, and now I propose to create a simple backup system that will be triggered upon the occurrence of certain events in iCal. To do this, we will use it as an opportunity to remind you of the event to launch a specific application or file.
In Automator, select the new template type - "Reminder iCal», after which in the workflow window overtighten the three steps from the category "Files and Folders":
- "Get these objects Finder» (select the desired folder for backup using the Add button).
- "Get the contents of folders" option selected "Repeat for each identified sub-folders."
- And the "Copy objects Finder» (you must specify the destination directory for it and allow to replace the existing files).
Once you save the process starts and iCal events with the name of your process will automatically be added in the near future. You can change an event on your own, as well as to create a completely new, independent event, pointing out the need to run our program in reminders section:
Quit all apps
Sometimes you need to finish all running applications that prevent working or have taken almost all the available computer resources. In this case, you can use a special utility like Blitz, One of the tips focus on Mac OS X or to start "from scratch" by closing all applications in one fell swoop.
Such workflow requires only one action, drawn as a program. And the name of this action is the same - "Complete all programs" (it is in the "Utilities" category). You also can add some applications to the exceptions. In "difficult moments" is enough to start our mini-application, wait for some time and again to enjoy the speed of the Mac.
That's all for today! I hope that this article will help you not only to understand the wonderful and useful Automator tool, but also will significantly simplify certain routine operations. Do not be afraid to experiment, because if you want you can take as a basis for any of the above examples and modify them to your liking.