Repeat Macro if more than one file Selected

If your objective is to rename every file in a selection, it will be much easier if you can use the macOS Finder. For example:

Here's the complete macro:
###MACRO: Rename Finder Selected Files With Sequential Number

If you must use PathFinder, then you will have to adapt.
There have been numerous topics/macros posted about using PathFinder.
See Posts with "PathFinder"

As I see it, you have two choices with PathFinder:

  1. Get a list of POSIX path of the files in the PathFinder selection, then process using the KM For Each action (KM Wiki).
  • Write an AppleScript to process the files in the selection.

#1 should be much easier.

Here is a JXA script to return a list of POSIX paths from Finder or PathFinder.
I have tested with "Fnder", but NOT with "PathFinder", since I don't have that app.
Can you please test this script in the Script Editor for a PathFinder Selection?

(function run() {    // will auto-run when script is executed.
    
    //--- CHANGE TO APP YOU WANT TO USE ---
    var ptyAppName = "Path Finder";  // "Finder" or "Path Finder"
    
    var fileList = Application(ptyAppName).selection();
    return fileList ? fileList.map(getPOSIXPath).join("\n") : "";

//~~~~~~~~   END OF MAIN SCRIPT ~~~~~~~~~~~

function getPOSIXPath(x) {
    
    var filePath = "";
    
    if (ptyAppName === "Finder") {
      filePath = decodeURI(x.url()).slice(7);
    }
    else {  // "Path Finder"  
      filePath = x.posixPath();
    }

    return filePath;
}  // --- END function getPOSIXPath ---

}  // --- END function run ---
)();  // --- END OF SCRIPT ---