Get Selected Items from Finder or PathFinder [Example]

MACRO:   Get Selected Items from Finder or PathFinder [Example]

~~~ VER: 2.0    2018-04-27 ~~~

DOWNLOAD:

Get Selected Items from Finder or PathFinder [Example].kmmacros (25 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.

As always, please feel free to post below any questions, comments, issues, and/or suggestions concerning this macro.


Use Case

  • Provide a utility that will work automatically with both Finder and Path Finder
    • Rather than force the user to use one or the other, allow the user to choose which Finder works best for him/her.
  • Get a text list of the items selected in whichever app is FrontMost
  • Script can be easily modified (one line) to force your app of choice
  • Demo how to use a KM For Each action with a item list in a KM variable
  • Use Local Variables that will be auto-deleted at finish of macro.

Example Results

image


ReleaseNotes

Author.@JMichaelTX

PURPOSE:

  • Get Items in the Finder or PathFinder Selection

REQUIRES:

  1. KM 8.2+
  • But it can be written in KM 7.3.1+
  • It is KM8 specific just because some of the Actions have changed to make things simpler, but equivalent Actions are available in KM 7.3.1.
    .
  1. macOS 10.11.6 (El Capitan)
  • KM 8 Requires Yosemite or later, so this macro will probably run on Yosemite, but I make no guarantees. :wink:

NOTICE: This macro/script is just an Example

  • You need to test further before using in a production environment.
  • It may not be complete. It is provided as an example to show you one approach to solving a problem.

How To Use

  1. Select one or more items (files or folders) in either Finder or PathFinder
  2. Trigger this macro.
  • It will then create a text list (one item per line) that can be easily processed in the KM Macro

MACRO SETUP

  • Carefully review the Release Notes and the Macro Actions
    • Make sure you understand what the Macro will do.
    • You are responsible for running the Macro, not me. ??
      .
  1. Assign a Trigger to this maro..
  2. Move this macro to a Macro Group that is only Active when you need this Macro.
    • In this case, it should be a Group when only Finder and PathFinder are available.
  3. ENABLE this Macro.
    .
  • REVIEW/CHANGE THE FOLLOWING MACRO ACTIONS:
    (all shown in the magenta color)
    • For Each Item in a Collection

TAGS: @Finder @PathFinder @PF @Selection

USER SETTINGS:

  • Any Action in magenta color is designed to be changed by end-user

ACTION COLOR CODES

  • To facilitate the reading, customizing, and maintenance of this macro,
    key Actions are colored as follows:
  • GREEN -- Key Comments designed to highlight main sections of macro
  • MAGENTA -- Actions designed to be customized by user
  • YELLOW -- Primary Actions (usually the main purpose of the macro)
  • ORANGE -- Actions that permanently destroy Variables or Clipboards,
    OR IF/THEN and PAUSE Actions

USE AT YOUR OWN RISK

  • While I have given this limited testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
  • If you have any doubts or questions:
    • Ask first
    • Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.

image

3 Likes

Thanks for doing this!

Trying to use it on a script that works fine on Finder but not on Path Finder.

Having an issue with Split Path – it doesn't work with Local__SelectedItemsList nor with Local__ItemPath. Regardless of whether I'm triggering from Finder or Path Finder I need to get Parent, File name, Base name and Extension to separate variables.

Any ideas on how to accomplish that, please?

This works fine for me:

image

If you still can't get it to work, please post your macro below.
See How to post/upload your script/macro.

I was making some confusion with local vs global variables on KM, it is working like a charm now. Thanks for doing this!

It would be phenomenal to have similar functionality on oher programs I use to soft through media: Xee3, IINA and VLC. Do you think that could be possible?

Many things are possible with KM, especially when you including scripting. I don't know any of those apps, so I really can't comment. The best way to find out is to experiment. That really is the best way to learn.