Step through selected items (files and folders) in Path Finder

Can anyone recommend a method that would allow me to execute a KM macro for each file or folder currently selected in Path Finder?

I can {down-arrow} through sequential items in Path Finder. The problem I am trying to overcome is stepping through only currently selected items.

Path Finder provides me some needed functions that Finder does not. Unfortunately for me, KM does not have any Actions for Path Finder equivalent to, for example, (“For each Item in a Collection” set to “Path” in the collection “The Finder’s selection”).



Very helpful! Thank you. Has already saved me minutes, and will save me hours before the end of next week.

I’ve never penned a line of code, so I just typed what shows in your image into “Script Editor” (I assumed there would some such in OS X), hit “Compile” (which nicely formatted it as you show it, confirming that while I can not write, I am a good copyist), and pasted it into the KM Action “Execute AppleScript” (which rudely removed all the nice formatting — how did you get yours to keep it?). But it works.

It also made me aware of something — something which programmers must have the vocabulary to describe. Because I don’t write code, my use of KM is almost entirely based on mimicking user actions. The AppleScript you provided does not mimic user actions, and my existing KM macro, which creates a new folder with the same base name as the file and moves that file into it, and which I wanted to run on the selected files in Path Finder, immediately failed. (I was able to find a suitable KM macro that Peter had provided to a knowledge-seeker on this forum.)

In short, I was looking for something that literally ( :mouse: ) moved the current selection from one file in Path Finder to the next file among a group of specified-by-selection files. What you provided supplies, one by one, something that is recognized as each file, without, afaict, doing anything visible in the UI at all.

What is the term for the distinction — or the distinct approaches — I’m trying to limn above?

More importantly, how does KM know to treat the file path/name as a file, and not as text? It just seems quizzical to me that I can tell KM to, per your example, “open” this string, and it opens a file.

I’m always learning. Thanks.

This works for me:

Enclose File in Folder (Path Finder).kmmacros (5.3 KB)

I must be missing something… What is it you are trying to do anyways? :flushed:

Me? Apologies if I am the source of your confusion. I am trying to do two things. To wit:
— 1. Get my macros to work with Path Finder selections. They work with Finder selections. This has been solved (my thanks to carycrusiau). The solution does not work with my macros, which all involve mimicking (not substituting) user actions. But it allows use of other macros, which do work.
— 2. Understand (better) how all this works. It seemed clear to me that carycrusiau’s solution required a parting of the ways. I am used to writing KM macros that mimic user actions. carycrusiau provided a solution that works behind (for lack of a better word) the UI. I would like to understand what this distinction is, to what extent is it already recognized, and how I can use knowledge of this distinction to write better macros.

Is that more clear?