Creating macOS Monterey Shortcuts for Multiple files

richard moult
6 min readJan 2, 2022

--

Attention all macOS users! Have you upgraded to Monterey and find yourself drowning in a sea of repetitive tasks? Fear not, my friends! In this blog post, I’m going to share my experience with trying to automate multiple files at once using Shortcuts. Let me tell you, creating a new Shortcut from scratch was about as clear as mud. But fear not, I’ve braved the Shortcut wilderness and I’m here to shortcut ;) the learning process for you. So grab a beverage of your choice, sit back, and let’s dive into the wild world of macOS automation

Photo by Element5 Digital from Pexels

Requirements

Mac + Monterey (version 12.0.1 and above)

What’s a shortcut?

A shortcut is a quick way to get one or more tasks done with your apps. The Shortcuts app lets you create your own shortcuts with multiple steps. For example, build a “Surf Time” shortcut that grabs the surf report, gives an ETA at the beach and launches your surf music playlist. You can read more from the Apple docs here https://support.apple.com/en-au/guide/shortcuts/welcome/ios

Explore

(feel free to skip this bit and jump straight to the next section, “Automation Task”, below)

The best way I found to start off with was to enter the ShortCut area and explore the Shortcut gallery.

You can open Shortcuts by either selecting the App in your Application folder (no install required), or cmd+space then type in “shortcuts”. You should be presented with something like

Select “Gallery”, then scroll the top horizontal list to “Starter Shortcuts” and select, giving you something like

Select a shortcut that interests you.

From here you can either “Add shortcut” which adds it to the “My shortcuts” section in the left panel, or select the more icon (3 dots) to see the details

Automation Task

As an iOS developer I need to add screenshots to my PR’s so the reviewer can get a good idea of what I’ve done. I’m using Bitbucket, for which there is a little faffing around with images, so I tend to always shrink the screenshots to a hight off 240 pixels (just a random height I feel works nicely).

Currently I take a bunch of screenshots using the iOS simulator, open them in Preview, select all the images, then use the resize tool to shrink them down to a height of 240 pixels. It would be awesome if we can create a Shortcut to do this repetitive task for me in one go.

Creating the Shortcut

In the main Shortcut menu, select “My shortcuts” / “All shortcuts” , in the top bar you should see a “+” icon, select that to start with an empty Shortcut.

I am interested in creating a Shortcut that takes in multiple images and resizes them for me. So the first task we would like to add is to be able to select some files. To do that, in the right panel, select “documents” and if you scroll down the options you’ll see “Select file” (once you get used to the options available you can jump straight to the search field at the top of the right panel)

To select that script you can either double tap or drag and drop on the main area.

By default, “Select File”, will only select one file at a time, we want multiple files, so select “show more” and tick “select multiple” option.

Next we need to iterate over all the selected files. Search in the right panel for “repeat” and select that script. Once added, the repeat task will have files auto selected for you (thanks Apple)

As we can select any file type but I only want to resize files that are images. In the right panel search field, enter “if” and drag and drop the “if” script below “repeat with each ….”

“Repeat item” is pre-selected for us, but in this case we want to change that to “media type”. Select “Repeat Item”, then select “Image” and “Media type”, see below

Select Condition as “is” then “value” as “Image”. Now the script knows that each “Repeat Item” is of type Image, we just need to add a script for “resize” and another for “save”. See below for the final script

If you now run this script, a finder window will open where you can select multiple files. For each file which is an image it will be resize to a height of 240 pixels and another finder window will open to save the resized image to a folder location of your choosing. For each file that is not an image I display an Alert just to inform that a selected file cannot be resized.

It is a bit cumbersome for me to keep selecting the save location for each image. I don’t want to keep the original image, so we can stop the system asking to save each photo and override by selecting “show more” on the “Save” script . Override the image that is currently there without needing the users permission for each image, like so…

That's it, now I have a handy shortcut to automate one of my common tasks.

But we can do better, in my opionion its best to be as lazy as possible. In the next post we’ll see how we can have this Shortcut easily accessible so I don’t need to open up the Shortcut app each time we want to automate this task.

Hope you found this helpful.

If you found this blog post helpful, you’ll love the book packed with plenty of real-world examples and AI integration — dive deep into Shortcuts.

If this has inspired you to create your own Shortcut you might find the links below useful.

Make your Shortcut easily accessible

Dynamic Shortcuts

Create a RSS feed viewer Shortcut

How to use an API in a Shortcut

Inspiring Shortcuts to learn from

--

--