Quickly Opening Specific Folders and Moving Items To Specific Folders

Until a couple years ago, I didn't use the Finder's "Go To Folder" menu item, because I found it almost useless. Then it dawned on me that it would be VERY useful if it only had an extensive list memorized and from which I could choose. So I wrote three KM macros to add this functionality, and I now use these macros daily. They have become indispensable time-savers for me. I figured some of you could benefit from them, too.

There are three macros included. The first (Daily Rebuild Paths List) is one that can be manually invoked at any time, of course, but I have it set to run once each day at a time that I am unlikely to be sitting at my computer. That's why the cron trigger is set for 20:00 each day. Obviously, you can set that to whatever time you want or change the trigger altogether. This first macro just rebuilds the list each day, so that any folders you create each day are included in the list when the list is rebuilt. This macro just sets things up for the other two macros. Don't try running the second or third macro until you've run the first macro at least once, because the other two macros rely on the text file (the list) that the first macro creates. Let the first macro run until the announcement window closes, which will take several seconds.

The second macro (Go to Folder) is for use when the Finder is active. It does just what its name suggests. When you trigger it (I have the trigger set as command-shift-G), then you will be confronted with a Prompt With List. Just start typing any part of a path and using the up and down arrows to find a folder you'd like to switch to, then hit Return. That folder will open in the Finder.

The third macro (Move to Folder) works very similarly to the second, except you should first have one or more Finder items selected before invoking it (by command-shift-M, unless you change the trigger). After choosing the destination, the selected items are moved to that destination.

Notice that I have named the list PathsMacBook.txt, and you may, of course, name that file anything you want. Be sure, however, that you make the change to every instance of that file name in all three macros. I suggest trying it out "as is" first.

Both of the yellow actions in the first macro are optional. If you delete them, then the macro will make a complete list. But a complete list, for me, actually has a lot more folders in it then I want. So these yellow actions exclude certain folders (and their contents) from the list. One of them excludes the Library folder, and the other excludes the Trash. Duplicate these actions and adjust them as you see fit to exclude any other folders that you don't want to pop up in the list.

One final note: if you use Google Drive and want to include it on the list, that takes a couple extra steps (not included here). I'll be happy to show you how.

Daily Rebuild Paths List Macro (v9.0.6)

Daily Rebuild Paths List.kmmacros (7.1 KB)

Go to Folder Macro (v9.0.6)

Go to Folder.kmmacros (2.9 KB)

Move to Folder Macro (v9.0.6)

Move to Folder.kmmacros (2.6 KB)

You can actually exclude these from the find command:

find "$HOME" \
-type d \
\( ! -ipath "$HOME/.Trash/*" -a ! -ipath "$HOME/Library/*" \) \
-print

Line 1: Look in $HOME
Line 2: Just for directories (-type d)
Line 3: Excluding paths that include ~/.Trash and ~/Library
Line 4: Print the result

Line 3 could be extended to include as many directories as you want:

\( ! -ipath "$HOME/Dir1/*" \
-a ! -ipath "$HOME/Dir2/*"  \
-a ! -ipath "$HOME/Dir3/*"  \) \

and so on.

Note that the \ at the end of the line can be removed if you put it all on one line, but you must put \ before ( and )

1 Like

I appreciate the alternative, tjluoma. I was thinking that performing the exclusions via KM actions would maximize the number of potential users (i.e., would "scare off" the fewest people).

Fair point, I am a big fan of showing people how to do things in Keyboard Maestro on the Keyboard Maestro forum :smiley:

…but since they already need to use a shell script, they can just copy/paste what is shown here.

Never hurts to know more than one way to do something!

Is there an easy way to make a list of folders in Keyboard Maestro and loop through it to formulate the kind of find command @tjluoma used? That would eliminate the need to make a bunch of KM steps and avoid the typos that are common when editing a long command.

Yes, I'm sure there is a way, but I'll leave it as an exercise, because, in my own use, it's just as easy to copy and paste a yellow action and configure it for a different folder to exclude.