Automatically Moving Files With Folder Actions

You can use Automator to create a special action that acts on files added to a folder. In this example, we'll create an action that looks for new screen shot files to appear on the desktop. It will then move them to another folder. You can look at a special controller to see which folder actions are active on which folders, and disable ones you don't need at the moment.
Video Transcript / Captions
Closed captioning for this video is available on YouTube: Automatically Moving Files With Folder Actions.

Folder Actions are a special type of Automator script that you can create that acts on new files put into a folder. So when you go to create a new script in Automator you can see Folder Actions right here and select it.

You can see here, Folder Actions receives files and folders added to a folder that you choose. So as an example, let's pick a folder that something gets thrown into like the Desktop. When you take a screenshot it appears on the Desktop. But say we don't want it to appear on the Desktop. We want to move it somewhere else. So everytime a screenshot is taken it goes to the Desktop and we want it automatically moved to a folder.

So we'll choose as the folder the Desktop. So anytime a file or folder is put on the Desktop this will run. Now, we don't want this to happen to just any file that goes onto the Desktop. We want it to happen only to screenshots. Let me take a screenshot here. I'm going to use Command Shift 4 to grab a section of the screen, it takes a screenshot and places it on the Desktop. I can see here that it's got a file name Screen space Shot space and then more information.

So let's look for this at the beginning of the file name here. We'll go and we'll apply Filter Finder Items. So anything that gets dropped into the Desktop we're going to look for If the name begins with Screen Shot. If it matches that exactly then it will do something.

Now what do we want it to do. Well we have another folder here. I've created a folder here in the Documents folder called Screen Shots. This is where we want that file to go. So we'll go and we'll look for Move. Move Finder Items. Great. So anything that passes this first test, having a name that begins with Screen Shot, will move to and we're going to choose this Screen Shot folder. There we go. That's all this is going to do.

So we can see now clearly the Screen Shot folder. Get rid of this one we took. We'll save this. We'll save it as Handle Screen Shots. Now it's saved as a Folder Action. We can Control click on it and see that Folder Actions are saved in Library, Workflows, Applications, Folder Actions, Handle Screen Shots. We'll make sure it is saved and we will try it out by taking a screenshot. I'll do Command Shift 4, take a little screen grab, we'll see it appear here. We'll look here for the little Automator running icon. You can see it ran there and now it moved into this folder.

Anytime I take a screenshot it will temporarily be there and a second or two later Automator will then run the Folder Action and throw it into this folder here.

Now one last thing I want to show you is that if we go to the Desktop here and let's actually go up a level here so we can select the Desktop folder, I'm going to Control click on Desktop and under Services we can see Folder Action Setup. This brings up this dialogue box here where we can see Folder Actions are enabled. There's one Folder Action and it's applied to the Desktop. When I select it you can see which one it is. I can temporarily turn it on and off with this checkbox here. I can also add a new one. You can see there's a bunch of preset ones that are included. I can Delete this one from there. I can also Edit it which opens it up in Automator in case I didn't actually have it opened before and need to find it without digging into the Library folder.

So that's a little bit about Folder Actions and one little useful thing you can do with them.

Comments: 2 Responses to “Automatically Moving Files With Folder Actions”

    2 years ago

    If one later decides to get rid of the automator scrip, will the files that used that script still be where they were put; in this case, the documents folder? I would think so, but just checking.

    2 years ago

    Darrell: Yes. The script just moves them, the same as if you were to do it manually.

Comments Closed.