Automator mac os examples. Five Automator procedures for those who value their time. Text from PDF

💖 Do you like it? Share the link with your friends

Automator is an application from Apple that automates repetitive procedures performed on a computer. In Automator, users can build arbitrarily complex workflows from modular blocks that call actions. Actions perform discrete tasks, such as opening a file, cropping an image, or sending a message. A workflow is a series of actions in a specific sequence, when the workflow is executed, data flows through the pipeline from one action to the next until the desired result is achieved.

Apple provides a set of pre-built actions with Automator, but developers are encouraged to add their own actions. You can create actions that are implemented as downloadable bundles of either AppleScript, Objective-C, or a combination of the two languages. You can also create actions using scripts or other scripting languages ​​such as Perl and Python.

Automator was introduced in OS X version 10.4. It does not work on earlier systems. Automator development features were introduced with Xcode 2.0. Additional features have been added in Xcode 2.1.

Any developer can create actions for Automator, as can system administrators or "Power Users" who are familiar with AppleScript. But application developers have a special motivation for developing actions. They can create actions that access specific properties of their applications, and then install those actions with their applications. Automator users can then understand what applications they need and what they can offer.

Developers can also contribute to Automator by making their applications script-based or by providing a programming interface (via a framework) that developers use when creating their actions.

Example of a simple Automator program

In this example, we will create an Automator program that will compress a folder we define into a zip archive and rename this archive according to the current date.

Launch Automator and select create a new program.

In the added action, select the folder that we want to archive.

We return to the list of actions, in the same “files and folders” section, select the “Create archive” action, and similarly drag it into the workflow field under the previous action. Here we can enter the file name of the resulting archive.

We return to the list of actions again, and again in the same “files and folders” section, select the action “Rename Finder objects” and, similar to the previous steps, drag it into the workflow field. Here we select the date format to be added to the file name, as well as the method of adding and the separator.

Now let's run this simple example in Automator and make sure it works.

At the end, we will save the resulting Automator program, and if we selected “Create a program” at the very beginning, then every day, without directly launching Automator itself, we can run the program we saved, which will make a daily copy of the specified folder.

A robot programmed to follow your instructions - who would refuse that? Unfortunately, many users think about Automator Mac's newest automation tool is like a toy for beginners who are too scared to learn AppleScript. In fact, Automator can be very powerful - especially when combined with other OS X features such as Unix commands, built-in image processing, and even AppleScript.

Here are five useful/fun (underline as appropriate) Automator procedures that will make you the envy of all computer geeks in the city 😉

You can do all 5 procedures that will be discussed.

First, launch Automator (in your Applications folder) to get started. Now decide on an application that can perform the action you need and click on this application in the “Library” column, then in the adjacent “Actions” column, select the appropriate action and drag it to the script construction area (Workflow). (The applications and corresponding actions that we will use are highlighted in bold below in the text.)

If you want to save the Workflow, select File > Save. If you want to save the procedure as an application (so it can be launched by double-clicking), select "Application" from the File Format drop-down menu in the save dialog.

So, let's start practicing.

Back up Word documents

Everyone knows that backing up important files is a good idea, but many people forget to do it. This procedure makes backup easy; when you run it, all recently modified Microsoft Word files in your Documents folder are archived and then burned to CD. Run this process every week and you'll never lose more than the last few days of Word work.

1. Finder: Find Finder Items This action searches for all files on your hard drive that meet a specified criteria. First, click on the Where drop-down menu and select Documents, so the procedure will only search in your Documents folder. Next, from the Whose drop-down menus, select Date Modified on the left, and select This Week on the right. Click the plus sign (+) to add another criterion. In the new pop-up menu line that appears, select Extension in the first menu. In the next one, put the value Is Equal To (equivalent) and then the document type doc in the text field next to this menu. This procedure will now look for files in your Documents folder that were changed this week and are Microsoft Word files.

2. Finder: Create Archive When you run your procedure, this action takes all the files found in the first step and compresses them into a single ZIP file. In the Save As field, define a name, for example this: Word files backup (Word backup files).

3. System: Burn A Disc This action puts the compressed file from step 2 on its own blank CD (or DVD). Specify a name in the Disc Name field, for example “Word Backup CD”, and check the “Append Date” checkbox, so the CD name will contain the recording date, which will make it easier to find later.

4. Finder: Move To Trash This action moves the ZIP file created in step 2 to Trash.

Other ideas: If you want to duplicate something other than Word files with this procedure, simply change the criterion in the first step; you can set any type you want (HTML, for example).

To make the process even more convenient, use the alarm function in iCal to schedule it to start automatically. To do this, save the procedure as an attachment, as described at the beginning of this article. In iCal, select File: New Event, select View: Show Info, click the Alarm drop-down menu, and select Open File. In the dialog box that appears, select your procedure.

Getting information about your Mac

Do all the Macs in your class have the latest version of OS X? Do you find that you often find yourself desperately searching for information about your computer's RAM when talking to Apple tech support? Even though OS X includes a System Profiler utility for getting information about your Mac, it's still difficult to keep track of all the statistics at once. This procedure extracts all the profile information from your Mac and returns it as a text file.

1. System: System Profile Click on Options and turn on Show Action When Run. When you run the procedure, it will ask you about what part of the computer you would like information about - software, printers, AirPorts, etc.

2. TextEdit: Filter Paragraphs In step 1, we get one large piece of text containing the profile information filtered by your query - but this text contains a lot of empty lines. To remove them, set the Return Paragraphs parameter in the drop-down menu for this action to Are Not Empty.

3. TextEdit: New Text File This action saves the text received after step 2 into its own file. Enter, for example, “Profile.txt” in the Save As field, and then select your Documents folder in the Where pop-up menu - the profile will be saved here.

4. Finder: Open Finder Items This action opens the file for viewing. Leave the Open With drop-down menu set to Default Application to open the file using TextEdit, or, depending on your needs, choose another application that can read plain text, such as Microsoft Word or Apple Safari.

Other ideas: If you need to call Apple technical support, print out your profile generated by this procedure so you can contact it. If you manage a computer lab, use text reports generated on each machine to create system statistics.

Make man pages more digestible

When learning Unix commands, such as grep or uptime, experts first turn to manuals for help using the man command. This procedure will save you from opening the Terminal and straining your eyes to read this text in an inconvenient format. Instead, you can open any manual page in TextEdit and print or save for easier reading.

1. TextEdit: Ask For Text When you run a procedure, this action will help you identify the correct man page. In the Question field, enter something like “What Unix command would you like to learn about today?”, i.e. What Unix command would you like to learn today? And select the Require An Answer option.

2. Automator: Run Shell Script Use this action to run Unix commands that locate and generate the man page for TextEdit. Select As Arguments from the Pass Input drop-down menu. Then enter the command man “$@” | col -b in the large text field (see first screenshot, A).

3. TextEdit: New TextEdit Document This action opens the newly generated manual page in TextEdit.

Other ideas: Save a frequently used man page (for programming languages ​​like Perl or Ruby, say) as a text file, and keep it in your documents for quick access.

Surveillance camera installation

If you have a digital camera, then there is some chance that your Mac can make it take pictures while connected to your computer. (The camera must be able to take photos when it is connected to USB. The first step in this procedure will tell you if it can do this.) This routine will tell the camera to take a photo every 10 seconds, compress it into a small JPEG, and repeat until you stop the program. This can be useful in many situations - when you're trying to figure out what your dog is doing when you're not home, for example, or if you want to make a slow-motion video without buying additional software.

1. Image Capture: Take Picture This action tells the camera to take a photo. If your camera has limited memory, select the Delete Image From Camera After Download option. If your camera has a large memory card, naturally you don’t have to enable this option, so your photos will be on both the camera and your Mac.

Note that this action automatically saves the pictures in the Pictures folder. If you want to save the photos in a different location, add a Finder: Move Finder Items action to the procedure and define where you would like to save them here.

2. Preview: Change Type Of Images This action gives you the opportunity to convert photos to more cost-effective formats, this is especially useful if your camera shoots in TIFF or Raw format. When you paste this action into your procedure, a dialog box will appear asking if you want to add an action that will copy your snapshots before changing them. Click on Don’t Add, this will prevent you from making 2 copies of each photo. Then, to save more space, select JPEG 2000 from the To Type drop-down menu if your graphics editor supports this format - Apple Preview, Adobe Photoshop and Photoshop Elements do. (If you use Photoshop, you may need some plugins from the installation disk). Otherwise, just select JPEG.

3. Preview: Scale Images This action compresses the size of each photo to save even more space. You will see the same dialog box when you insert this action into your procedure. Click on Don’t Add again. Unless you need these photos in high resolution, although the standard size of 480 pixels is usually sufficient.

4. Automator: Pause Add this action to force Automator to pause before taking the next photo. Enter 10 in the text field to force the procedure to pause for 10 seconds. Before you move on to the next step, save the procedure (as Workflow) and give it a name.

5. Automator: Run Workflow To force the procedure to take the next image, you need to force it to repeat the steps. This action restarts it again. From the Workflow pop-up menu, select Other, and then select the procedure you saved in step 4. Now save the procedure under the same name again.

To test your new program, run the script with the Run button. When you have finished taking images, you can interrupt the execution of the script by clicking on the Stop button.

Other ideas: When you've stopped the process, drag images into iMovie to make a time-lapse video. You can also use the same Automator to force QuickTime Pro to make a slideshow - a 2-step task!

One of the most underrated tools on Mac continues to be . It is thanks to this utility that it is possible to automate a huge number of daily routine tasks. In this material we will give examples of 6 ways to use Automator with your favorite browser on .

In contact with

Opening a web page at a specified time every day

On weekdays I get up at six in the morning and leave for work by eight o'clock. Every time ten minutes before going out, I check the weather to figure out what to wear. So why not make the forecast open automatically at 7:50 on weekdays? Automator can easily handle this and other tasks described below.

1 . Run (open explorer FinderPrograms or launch it via Spotlight search (keyboard shortcut Control (⌃)+ space).

2 . In the pop-up message, select " new document».

3 Calendar notification", and then click the " Choose».

4 . In the left side menu in the section " Libraries" Choose a section " Internet».

5 . In the second column, find the parameter “ Get specified URLs"and drag it into the workspace located on the right.

6 . Remove the suggested web address and add the one you are interested in.

7 . Now from the second column drag the parameter " Display web pagesGet specified URLs».

8 . To check the functionality of our script, click the " Launch" in the upper right corner of the Automator window. The default browser should open and the specified page should open.

9 File → Save As... and save the calendar notification.

10. After the regular calendar opens, select the current day and event. In the right side menu, specify the start and end time of the event, as well as the repeat time, for example only on weekdays.

Now every day at 7:50 a.m. a notification will arrive on my Mac and a page with the weather will open. It’s also a good signal that it’s time to get ready for work.

Opening multiple favorite sites

Thanks to this mini-instruction, you will learn how to create a small algorithm that allows you to launch a few selected web pages. For example, you are browsing a group of news sites at a certain time. Every time you have to open the same tabs, but they clicked on a special application, and everything was in plain sight.

1 . Repeat points 1-2.

2 . Specify "Document Type" Program».

3 . Go to the section again Internet" and drag the parameter " Get specified URLs» into the workspace.

4 . Add a few favorite sites.

5 . From the second column, drag the parameter " Display web pages" into the workspace immediately below the block " Get specified URLs».

6 . In the menu bar, go to the section File → Save As... and save the new program.

By launching the created program in the default browser, all tabs of interest will open.

Downloading all images on a page

Undoubtedly a useful option for a number of professions such as designers, journalists, and ordinary users. With such a utility, you will no longer have to download dubious widgets or sort through pages with code. The only negative is that you can only work in the Safari browser. If you know a way to perform a similar operation with other browsers, be sure to post in the comments.

1. Repeat points 1-2.

2. Specify " Process».

3 . Go to the section " Internet", but this time drag the parameter " Get current page from Safari».

4 . Next, drag the parameter “ Get images URL from web page" and in it select the option " on these web pages».

5 . And at the end add the parameter “ Load URL" and, if necessary, specify the download folder.

6 . In the menu bar, go to the section File → Save As... and save the new program.

Now to download all the images, open the page of interest in Safari, go to the folder where you saved the script and run it.

Will open . All you have to do is press the button " Launch" in the upper right corner and wait until the files are downloaded.

Downloading all audio and video files from a page

Well, now we will create a more specific, but no less useful script, thanks to which downloading almost all media content will not be difficult.

1 . Repeat points 1-3 previous instructions.

2 . Now drag the parameter " Get link URLs from web pages" If you leave a checkmark in the checkbox, all audio and video files will be downloaded from the domain on which the page is located, and if you uncheck it, all files from the page will be downloaded, regardless of what domain they are located on.

3 . Add the parameter " Filter URL" Thanks to the filter, you can specify your request.

For example, if you want to download only MP3 files, then in the bundle “ Path - contains" add " .mp3" (without quotes), if the video is in MP4 - " .mp4", and so on.

4 . Well, now it remains to add the already familiar parameter through which we indicate the location for saving files - “ Load URL».

Downloading using this script is carried out in the same way as in the previous paragraph.

I downloaded a selection of Mozart’s compositions in one click, otherwise I would have had to download each track separately.

Run web pages as a separate application

I don’t know why such a script might be needed, but if it’s possible, then someone definitely needs it. You can tell us about your options for using this lotion in the comments.

1 . Run Automator → New Document → Program.

2 Get specified URLs" and add the web address of interest.

4 . In the menu bar, go to the section File → Save As... and save the new program.

By launching a new application (in our case, “Yablyk”), the specified website will open in a separate dark window. It will appear on top of all windows.

Opening titles containing specific keywords

Sometimes it can be difficult to find something useful even among hundreds of RSS headers. With Automator, you can run keyword searches among the titles of your favorite sites.

1 . Run Automator → New Document → Process.

2 . Drag the " Get specified URLs" and add an RSS link to the web address of interest.

To do this, go to the resource page and look for the icon or inscription with RSS. The link usually contains the word " feed».

4 . Drag the parameter " Extract URLs from articles" Attention! Some sites (including the website) require you to uncheck the box in order to receive addresses from different domains.

5 . All that remains is to add the parameter “ Display web pages».

6 . Save the script and click the " Launch» to initiate the process.

After launching in the default browser, all tabs containing the specified keyword in the title will open.

And in the comments, be sure to write about your favorite use cases. .

The built-in automation tool “Automator” in Mac OS X can work wonders. However, many Mac growers ignore the program, considering it useless. To counter such judgments, here are five amazing Automator secrets from Snow Leopard.

1. Universal access to the media library

If you often work with iLife and iWork packages, then you are probably accustomed to using the built-in media browser - a panel that gives access to videos, photos and iTunes songs. However, due to the lack of this panel in other applications, users are forced to open the Videos, iPhoto or iTunes folder separately. Automator solves the problem.

Go to the Mac OS X Automation website and download the script

For example, to automate the backup of files from your desktop to another folder (for example, on another drive), specify the iCal Reminder template and create a sequence of actions like this: Get specified Find objects er, Get Folder Contents, and Copy Finder Items. (In the Files and folders section in the first column). Move the source folder for backup to the first step, leave Retrieve contents of folders as is, and in Copy Finder Objects specify the destination of the files (Backup folder). Now, when you click the Run button, you will see that all objects from the desktop will appear in the Backup folder. (To replace old files in a folder, check the “Replace existing files” checkbox).

When you save the process, the program will ask you to name the iCal Reminder, and then launch iCal with the event editing window. Here you can create a recurring event. For example, every day at 4:00 a.m. all files on the desktop will be backed up to another folder.

Note: Automator allows you to set up automatic desktop cleaning. Imagine, all the documents, photos, videos and other files accumulated during the day are miraculously sorted into the right folders when you turn off the computer. Setup instructions

4. Automatic import and slideshow

Automator includes an image capture plugin that is also incredibly useful. Create a new album in iPhoto (File -> New Album) and name it Photos of the Day. Open Automator, start a new process and select the Image Capture Plugin template. In the first window, in the Libraries section, select the Photos object and create a process as follows: View photos, Import files into iPhoto, Get selected iPhoto photos, Play iPhoto slideshow.

In the Import Files to iPhoto action, specify Existing Album and Photos of the Day, and in the Get Selected iPhoto Albums, select Albums from the drop-down menu (which will change the action name to Get Selected Albums). Save the process (File -> Save) and name it Review and Slideshow.

Now connect your camera to your Mac (this could be an iPhone or iPad). Open Image Capture and at the bottom of the window, click Browse and Slideshow. Select the appropriate images and click the Import button. Now comes the fun part. After a couple of seconds, the View Image window will appear with the first photo, where you need to use the Reject and Approve buttons to filter the photos for import into iPhoto. iPhoto will then open, add the verified images to your Photos of the Day album, and start the slideshow!

5. Text from PDF

If you're looking for an easy way to extract text from PDF files, use Automator. Create a new Automator process and select Program in the templates window. Start a process with the following actions: Retrieve selected items from Finder (section Files and folders) and Extract PDF text (section PDF files). To make your text look better, switch to Rich Text in the Extract PDF Text step. Specify a location to store the file, such as the “PDF to RTF” folder from the Save output to drop-down menu.

Now save the Automator application to your desktop. When you're ready to convert, drag any PDF document onto the created application icon. Automator will then extract all the text from the PDF and place it into a new text document inside the specified folder.

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

Batch renaming images

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

To launch the utility, you just need to either find its icon at the top of the Applications directory, or use your favorite application launcher/system Spotlight. And after a few seconds, the 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 a *.app extension.
  • A "service" is a process that is context specific and can be used across the entire system or individual applications.
  • The “folder action” is launched only for the folder specified in it 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 the corresponding application to process photos uploaded from the camera.

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

The option located at the top of the process window (right below the toolbar) requires you to select a folder. It is for this that our actions will be performed:

Everything we may need to solve a problem is located in the “Files and Folders” category. First, you need to find and drag an action called “Rename Finder Items” into the workflow window. Because Automator changes their names, we'll be prompted to automatically add another action that allows us to save the original files to a different folder (I chose not to save copies, but that doesn't mean you have to do the same).

Now in the very first drop-down list of our action, you need to select the “Make consistent” item and configure the format of the new name as you wish. This is quite easy to do, as there is an example at the bottom of the action.

To add the current date to the file names, you need to drag the Rename Finder Items action into 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:

Bulk image resizing

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

However, before rushing to solve the problem head-on, I suggest drawing up a sequence of necessary actions. For example, first we should ask the user to select the photos whose size we want to resize. In addition, it is advisable to work not with the original files, but with their copies, so that you can always try new settings for our process. And we will copy the reduced images to a separate directory.

Now we can move on to creating our mini-program. First, you need to find and drag the Query Finder Items action into the workflow window under the Files and Folders category (or via the search bar). There you can specify the window title text, the starting folder and the data type. Don't forget to check the multiple selection checkbox.

To work with file copies, I suggest searching the Library for the “Copy Finder Objects” action, specifying the destination directory. The next action is in the "Photo" category and is called "Resize Image". In the settings you can specify the size of the resulting image in pixels or percentages.

By the way, in the bottom panel of each action there are three tabs: Results, Parameters and Description. Therefore, if you want Automator to prompt you each time to specify the required image size when performing this action, select the “Show action in progress” checkbox in the Options tab (if desired, using this option you can extend the previous process to specify a specific name 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 action.

And one more trick: by selecting the “Show action during execution” checkbox, the “Show only selected objects” option will become active. This way you will not be able to display the entire window with the action, but only some elements. For example, a field to indicate the required size.

And to complete the process, we need to transfer the thumbnail image to a new directory. To do this, we will need the “New Folder” action from the “Files and Folders” category.

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

Opening certain web pages when launching the browser

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

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

  • “Get selected URLs”, in the settings of which we indicate our favorite web pages;
  • and the “Display Web Pages” action to open them in the default browser.

Extract text from PDF

This is a fairly simple but handy script for Automator that can sometimes save time. It will allow you to extract text from a PDF document (of course, such a document should contain text, not scanned images) and save it into 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 into the workflow window and configure the settings as you wish:

Note that we didn't specify a "Query Finder Items" action in this process, so once launched, we can drag any PDF file we want to process directly onto our app's Dock icon. This file will serve as an input parameter for the process.

Save the contents of the clipboard to a text file

We continue to explore different Automator templates, and in this process I suggest creating a service that will save the contents of the clipboard to a text file that we specify. 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 what needs to be indicated in the drop-down list above the workflow window.

We need to give our service a human name so that we can easily find it in the “Services” menu of any application...

...and assign it, if necessary, a keyboard shortcut in the System Settings application.

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

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

Easy automatic backup

We continue to complicate the task, and now I 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 to serve as an event reminder to launch a specific application or file.

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

  • “Get specified Finder objects” (select the desired folder for backup using the Add button).
  • “Get contents of folders” with the “Repeat for each subfolder found” option selected.
  • And “Copy Finder Objects” (this requires you to specify a destination directory and allows you to replace existing files).

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

Quit all applications

Sometimes you need to end all running applications that interfere with your work or have taken up almost all the free resources of your computer. In this case, you can use a special utility like Blitz, one of the tips for concentrating attention in Mac OS X, or start working “from scratch” by closing all applications in one fell swoop.

Such a workflow will require only one action, formatted as a program. And this action is called similarly - “End all programs” (it is located in the “Utility programs” category). You can also add some applications to exceptions. In “difficult moments”, it’s enough to launch our mini-application, wait a while and again enjoy the performance of the Mac.

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



tell friends