Hi, this is Gary with MacMost.com.
Today let's look at how to create Finder Quick Actions using Automator.
MacMost is brought to you thanks to a great group of supporters.
Go to MacMost.com/patreon.
There you can read more about it.
Join us and get exclusive content.
So Quick Actions allow you to select a file and perform an action on them right in the
Finder.
Now there is some that you get built in with macOS Mojave.
But you can also create your own using Automator.
Let's look at two examples.
If you're not familiar with Quick Actions you see them in the Finder.
You select a file and in the preview area here on the right you'll see them at the bottom.
If you don't see a preview area here you can go to View and then Show and Hide Preview
right here.
Now notice I have a video selected so I have Trim and Rotate Left Quick Actions.
If I select another type of file, like an image, I'll get different ones like Markup
and Create PDF.
Other ones I may not get any Quick Actions.
The Pages document gives me nothing.
I can always click on More here and Customize and I can change which Quick Actions will
show up here in the Finder.
So I have four that are selected here.
So let's go and create one that is a custom one.
These are all defaults except this Watermark 1 which I created for a previous tutorial.
As a simple example let's create something that will create a backup of a file before
you work on it.
Say you have a graphics document and you want to make some changes but you want to save
a copy somewhere before you start messing with it.
So we'll use Automator to create a Quick Action here.
You see one of the options you get when you create a new document in Automator is Quick
Action.
So you want to select that and go to Choose.
Now we can setup some things for the Workflow.
Workflow receives the current what?
So we want to say files or folders.
Then we'll say not in any application but in the Finder.
This is going to be a Finder Quick Action.
Now we start to add actions to the workflow here.
So we're going to want to copy this file.
So we can use Copy.
We can search here and say yes there's Copy Finder Items.
A better thing might be there's an Archive and create an archive so this will compress
the file which will be useful.
The idea here is we're just creating a backup copy and we're probably not going to use it.
It would be nice to actually make that a little bit smaller in case we do this a lot.
So create an Archive.
Same name.
Save as as Empty.
Now we want to create a place for this to go.
So we'll select Other.
We'll go to the Documents folder and create an Archive Backups folder there and this is
where we'll keep all of these things.That's it.
It will just do that.
So let's Save now.
The first time we Save it's going to ask us for a name.
So let's call this Backup Archive and we'll hit Save.
Now we'll Hide Automator.
We don't need to close this just yet and we can select a file, a Test Numbers document
here.
You can see we get Backup Archive now there.
The reason it appears there is because there's no other Quick Action there so it immediately
jumped on it and said well I might as well fill that in there.
If we didn't see it or we saw other things there like, for instance, if I went to this
video I'm still going to see Trim and Rotate Left.
But I could hit this three dot button here and you can see Backup Archive appears.
I can also go to Customize and I can see these here and I can drag Backup Archive to the
top so it takes precedent over the other ones.
Now I can see it appear there.
Let's go and do a Backup Archive of Test.Numbers.
I'll click this and it runs.
You can see the gear appears really quickly at the top there.
Let's create a new Finder window and in the new Finder window I'll look for that folder
in my Documents folder here.
The folder is called Archive Backups and there is that zip file there which has that inside
of it.
We can look at it here and see it's 73K which is actually smaller than the 109K so it compressed
it for us really nicely.
Now any file we want to go and work on, say this Pages document here, we can click on
it, hit Backup Archive real quick, and then we can know that it's been saved, a copy's
been save into that folder.
So kind of a useful little Quick Action there because there's a lot of people who like to
duplicate a file before they work on it.
So let's look at another example because you can do so many things with Automator here.
I'm going to close this document there and I'm going to create a new Quick Action.
What I'm going to do with this one is I want to be able to read in Text files.
So I'll select Documents in Finder and what it's going to do is it's going to get the
contents of that document and speak them.
I could just search for Speak here and there's Speak Text.
You'd thing if I put that there now it will speak the text in the voice that I choose.
So let's save this.
We'll call it Speak Text File and it's Saved.
Now we'll hide Automator there.
Select the text file and it's not going to perform as we expect.
If I use this I'm going to hear the name of the file.
(Computer speaks.)
Actually the full path even.
So what it's clearly doing is, in Automator here, it gets the document and then it speaks
the path of the document.
So how do we get it to speak the text inside of the document.
This is where we can expand our Automator action using some scripting.
You can do Shell scripting.
You can do AppleScript.
I'm going to use Javascript for jxa as the more modern way of doing it.
We're going to create a quick jxa script that's going to get the contents of the file and
then pass that to speak text.
So I'll search here for Javascript and select Run Javascript.
I'll put that there and I can put my script right here.
So the script is fairly simple.
So I've just pasted it in.
It sets a variable app equal to the current application because Javascript needs to perform
actions using the application that's running.
In this case it's going to be the Finder.
Then it uses app.includesStandardAdditions equals true.
You need to do that in order to basically perform actions on that app.
Then it's going to get output equals to app.read which will read the contents of input.
Input in this case is going to be the document pasted in.
Then it's just going to return that output.
So output should be getting the text because it's a text file and then returning the text.
Then that goes into the Speak Text action so it should speak the text that's inside
the document.
Let me switch over to the Finder and I have the Text file selected.
I'll use Speak Text File which appears right here for it.
(Computer speaks.)
So it works.
Now note that this works with a text document because the contents are text.
If I select something else it may not work.
For instance this rtf document.
RTF is rich text format.
It contains all sorts of odd formatting and things.
So if it tries to speak this you'll get a whole jumble of stuff.
(Computer speaks.)
So I could stop that here using the little gear in the menu bar.
You definitely don't want it to try to speak the contents of an image or video.
It's purely for text documents.
There's so much more you can do with Quick Actions.
You can build all sorts of workflows inside of Automator and, as I showed, you can use
Javascript or AppleScript or even Shellscript in Automator to do more with files if you
know how.