Select by File Type and Move Them to a New Folder

This is so great! Thank you once again @ccstone.

In the past, I've learned a lot and "Frankensteined" together some useful macros for myself using your scripts. With this specific macro, I don't have the knowledge to accomplish what would be helpful for me. Using this macro, I get close, but no cigar, and I don't want to screw things up!

For me, this scenario would be ideal:

If within Finder, I could point to (highlight) a root folder that contains many other folders, and have KM search all of the folders within the selected folder for specific file types, then copy those files to a new folder within the originally selected folder.

How would one accomplish this?

Hey Ron,

This is a fairly straightforward task and only requires Keyboard Maestro native actions.

The only part that's a little tricky is where I test for the file extension with a regular expression.

-Chris


Finder ⇢ Extract Files of Given Types from the Selected Folder v1.00.kmmacros (9.1 KB)

Macro-Image

Keyboard Maestro Export

@ccstone to the rescue once again! Thanks so much, this is great.

Hey, Chris. I'm curious why you split the extension from the full file path rather than simply applying the regexp match (slightly modified) to the path itself. You must be accounting for some edge case where the results would be different. Yes? Curious what that is. Thanks. –Steve

Hey Steve,

I think the logic here is a tad more obvious for people not well acquainted with Keyboard Maestro and/or regular expressions.

File name extensions make more sense to most folks than complete path strings.

That said – as you mention – splitting the path is not strictly necessary for getting the job done.

-Chris

Thanks, Chris. Yes, absolutely true that your solution very clearly performs the operations specified in the problem. Without that extra step someone might well have asked a question like mine in reverse. Thanks for the response! –Steve

1 Like