Get Selected Finder Items - Plugin Action

Get Selected Finder Items

Get Selected Finder Items

    by Ian Kirkland



Description

This plug-in action allows you to bring the selected Finder items into Keyboard Maestro as a collection of items (in POSIX path format). In other words, it enables you to get and treat multiple files as a single unit (i.e. an array or list of items stored as a newline-delimited list, a format compatible with Keyboard Maestro). The action's options include the following:

  • Quoted or unquoted form of item paths
  • Whether or not to treat bundles as folders

Screenshots

Action Preview

Action Options

In-use (Finder)

Action Results


Additional Notes

If you come up with any creative uses for the action – or come across any deal-killing bugs – please share them here in the comments

I have a highly-involved 9-to-5 job that I'm very passionate about. Visit here if you want to know more: http://bradfieldproperties.com Better Homes and Gardens Real Estate Bradfield Properties. That said, I'm very busy, so I can't guarantee 'lickety-split' fixes. However, please feel free to report bugs and other frustrations at: ianthekirkland@me.com. In true n00b humility, please let me know if this plugin can be improved. (This is how we learn, and I am all ears.)


Download

Download Plug-in Action: km-get_selected_finder_items.zip (966.4 KB)


Installation

To install, drop the .zip file onto Keyboard Maestro and it will install it as a Third Party Plug In action. If, for some reason the install fails, simply unzip and place the resulting folder in the Keyboard Maestro Actions directory in Application Support. You can locate this directory by copying the below path, and – in Finder's menubar – selecting "Go > Go to Folder...". Then paste the path into the text field that pops up:

~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions/


Legal

THE SOFTWARE IS PROVIDED "AS-IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

4 Likes

@ianthekirkland -

That is very, very, nice!

My compliments to you for figuring it out and then building the action.

This is the first time I have seen a new action posted on this forum.
Macros, yes, plenty, but this the first action I've seen.
I'm impressed.

And, @ianthekirkland's work showed me that that users can add actions into KM.
I didn't know that before now.

Installation (by drag and drop) was easy.
The action worked smoothly the first time.
Here are the results:
.

From this in the Finder:

To this using "Get Selected Finder Items:

1 Like

Ian, thanks for sharing your plugin.

To make sure I'm not missing something, what is the difference between your plugin and the standard KM Action "For Each Item" in "The Finder's Selection" ?

1 Like

To be honest, there's not a whole ton of difference. I think it just approaches things with a slightly different mindset. It's kind of like how there's a "Copy" action now instead of just a "Type a Keystroke" with ⌘C as the default keystroke. I normally don't deviate from the DRY methodology, but sometimes a slightly different abstraction helps things 'click' with certain people. It's the same reason I like Ruby so much: it's conscientious of method naming conventions from other languages. For example:

array.map { |e| ... }

... is equivalent to ...

array.collect { |e| ... }

I guess what I'm trying to say is that it's a philosophical matter. :wink:

1 Like

When I first started working with KM, I wrote a lot of actions. Then I started posting macros that required those actions, and it was a hinderance to people using my macros - people don’t mind downloading and installing a macro, but add a custom action to it, and the number of users drops dramatically (although I have no numbers to verify this, I believe it to be true).

So I finally quit doing actions, except under special circumstances. Now I mostly use sub-macros, which often-ties aren’t as simple to use, but at least they’re easy to ship.

It’s too bad, though, because some things are just begging for custom actions. For instance, one of the things I do a lot of is taking a file path, and separating out the folder name, the file name, and perhaps even the extension. Of course this can be done with existing KM actions, but wouldn’t it be nice to have it all in one action?

So, keep up the good work, but beware the limitations when you want to share macros. And get used to the question “why can’t you just …”. :smile: By the way, it’s a perfectly valid answer to say “because I like this better”!

2 Likes

Reviving this thread years later to ask, how would one do this? I'd love to separate the entire filepath from the filename for instance. Newbie here. Thanks!

Hi @bog_standard - does this come close to what you’re asking - the KM Split Path action?

See the KM wiki page action:Split Path [Keyboard Maestro Wiki]

It does, you're a lifesaver! I was just on a regex crash course, this is much easier :slight_smile:

2 Likes

Hey Guys,

Keep in mind too the relevant text-tokens for Finder selections:

%FinderSelection%
%FinderSelections%
%FinderInsertionLocation%

-Chris

3 Likes