Open all the folders with a particular name

I would like to use Keyboard Maestro to open all the folders on my Mac that have (or start with) a particular name. For example, as a teacher, I keep annual folders. Each annual folder might have a folder for that year called "Professional Development", with a year suffix (e.g. Professional Development 17-18, Professional Development 18-19, etc.)

I would like to be able to hit a hotkey and have all the folders that start with "Professional Development" open up in tabs in PathFinder. Could someone point me to a macro I can adapt (my search of the forum didn't come up with anything close) or guidance toward creating one? Thanks!

The rest, below, is backstory and less relevant, if you don't want to take the time to read it. (My main point is above.)

As of now, I can use PathFinder to create tab sets. So, I could create a tab set with all the "Professional Development" folders in tabs. But, I'd have to update that tab set each year with the next year's folder, and then I'd have to do the same for every other folder set I need. If I can just have KM find and open all the "Professional Development" folders at once, that would be great.

I've considered changing my folder structure to something more topical instead of yearly, but since at least some of each previous year's material becomes obsolete, a topical folder structure quickly introduces a lot of "noise" and I end up missing important details. But, I do want to easily be able to go back to previous year's folders when needed.

If the best way is just to take the time to create these folder sets instead of investing the time in creating a macro, that's fine. But if such a macro already exists or someone kind provide guidance toward creating one, that would be appreciated too.

Hey John,

Give this a try.

-Chris


Open Folders Whose Name Starts with ‘Professional Development’ in Path Finder.kmmacros (7.0 KB)

Wow. Thank you Chris. That script action was the key.

Just for information of whoever else might find this thread userful:

For a while, I was not able to get the script to find folders on internal or external volumes if I tried to narrow down the path by replacing "~/" in the script with a more complete path, with the syntax:

/Volumes/ExternalVolume/Folder/Folder/

I discovered through experimentation that paths in shell scripts must have certain characters escaped, that is, a "" character placed just before them. I'm sure this is old news to anyone the least familiar with shell scripts, but the untrained should keep this in mind when attempting to modify the script to find along a path. According to my experimentation, the characters that need to be escaped are "(", ")", and " " [space]. I'm sure there are others as well.

––––––––––––––––––––––––––––––

Another part of what I'm doing is: I'm using this macro to find a folder of a particular name (without the asterisk in the script...and assuming the folder name is unique), so that the folder will be found wherever it is, or gets moved to, in my file organization.

That said, I'm wondering if I could also successfully find the folder if the name of the folder is changed. Don't individual files and folders also have inode numbers? I assume this a unique number that stays with the item for it's lifetime. If I could get a folder's inode number and find it by that number, then it wouldn't matter where I moved the folder or whether I've changed its name. (As long as it exists on the same volume, I assume.) Or am I off track...

Hey John,

The simplest way to go is to completely quote any given full path.

'/Volumes/ExternalVolume/Folder/Folder/'

** Note the single quotes.

You can't do that with home-based (tilde-based) paths though – the ~/ portion can't be quoted – because the shell won't correctly expand it if it thinks it's a string.

~/'Folder/Folder/'

** Note the difference in the placement of the single quotes.

I'm not aware of a method of doing that on macOS (but that doesn't mean it's impossible).

You can create an actual alias file to do much the same thing.

-Chris

Thanks for the tips. Ooo, I was bumbling around. Whadatheysay: "Even a broken clock is right twice a day." :slight_smile: