Move Files containing "Screen Shot" to another folder

Wow - A simple task but impossible to figure out:

I want to move all files containing the following text in their filenames, “Screen Shot” to another directory.
So in other words, a wildcard to select all files that have “Screen Shot” in their filename.

There doesn’t seem to be a way to pick those files up in the “For Each Item in a Collection Execute Actions” action. I chose “The files in directory” (browsed to ~/Desktop), then added the “Move or Rename a File.”

How to pull in those files with the text and a wildcard?

I’ve looked at something similar in other questions - but I can’t seem to find the exact actions.


Hi CB,

You're very close. The only step you're missing to select just the files you want is an If Then Else action to ensure that the only files acted on are those that meet the criteria you specify:

Process Screenshots.kmmacros (4.3 KB)
55 AM



Just make sure to change the destination folder to where you want the screenshots moved and this should get you started. Feel free to post again if anything is unclear or you have any other questions.

1 Like

@gglick has given you a good solution.

Another approach, that I would use, is for the files in the Finder.
2. CMD-A or manually select the files of interest
3. Use a KM For Each in Finder Selection

This method lets you have one KM macro that will work for all search criteria, and make use of the more powerful Spotlight Finder search features.


Which ought to be faster for this task: a macro as illustrated here by @gglick, or calling an AppleScript to do it all ?

Sometimes I’m torn between whether to build a macro out of several different actions, or write an AppleScript and bung it in there instead. About half of my “macros” are just AppleScripts.

1 Like

Hey @CJK,

In general AppleScript is more efficient for this sort of job.


Hey @agilefalcon,

It’s easy to do this job with AppleScript and a whose-clause using System Events – IF you’re not dealing with more than a few hundred files.

It only takes 6 lines of code…

# Auth: Christopher Stone
# dCre: 2018/03/24 12:33
# dMod: 2018/03/24 12:39 
# Appl: System Events
# Task: Move files whose name contains a string to a destination folder.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @System_Events, @Move, @Files, @Whose, @Name, @Contains, @String, @Destination, @Folder

set sourceFolder to path to desktop folder
set destinationFolder to alias ((path to downloads folder as text) & "Test ⇢ Destination Folder:")

tell application "System Events"
   set fileList to (files of sourceFolder whose name contains "screen shot")
   move fileList to destinationFolder
end tell


Of course I’m not doing any error-checking here, as I would in a production script.

Now then – let’s get a bit more sophisticated and use a regular expression to find our files:

AppleScript ⇢ Working with Files and Folders


Hi. I am trying to achieve something similar, except that I want any files saved to my downloads folder that contain "HBD" to be moved to a specific directory. Here is what I have but the macro isn't triggering. It only works if I press the "Run button".

Any ideas?


Hey there. Make sure the macro group is set to be active in the apps you want to use it in, and don't forget to actually assign it a trigger so you can run it outside the KM editor window :wink:


Hi @gglick. Thank you for the reply.

I want the macro to trigger as soon as the file (with HBD in the filename) is saved to the downloads directory.

I tried setting a folder trigger for ~/Downloads but it didn't work.

Any ideas?

No problem. First, again, make sure the macro group is enabled and active where you want to use it (maybe it already is, but I can't tell that from your screenshot alone). Second, if you only want to add files that are newly added, you don't need a For Each action, just an If Then Else to check if the added file contains HBD in its file name or not:


Thank you @gglick. I realized that it wasn't working because the macro was inside of a Macro Group that was only available in Google Chrome.

Everything is working now!

1 Like