Display List of All Files Selected in Path Finder

Hey Yall I am at a loss and I am sure its a simple fix.

I want my prompt for user input to display all of the items currently selected by path finder.

Currently, its showing a prompt for each file selected

EX
If I want to delete 4 files and I have 4 highlighted it will display a prompt for each file.

I would prefer 1 Prompt to list all 4 selected files.

I know my issue is that I have "For Each Item in a collection" I just can't figure out how to group them all together for 1 collection.

I have attached the Macro I discussed below.

Trash It Path Finder.kmmacros (31.8 KB)

If you are using a loop to go though each file in a list, then by necessity you are going to have as many prompt windows as you have files.

If you replace it by a single Prompt action then you can list all the files inside the Prompt action.

So I think what you have to do is forget about the loop. You want a single prompt which lists all the files in the prompt box followed by an action that deletes all the files.

Does that make sense? Do you need advice on writing that code?

yes I am just stumped on how to get the list of all the selections in 1 prompt / will the delete action work for them all teh way it does on the loop?

The script your macro uses is already returning a list of selected files in the variable Local__PFSelection, so @Sleepy is right; you don't need the For Each loop at all. All you have to do is include that variable in the prompt:

21)Trash It 1.1.kmmacros (30.5 KB)
image

42%20PM

Excellent Thank you for your help.

The filter action removed the file location and just gave me the file names, but only seems to work with the first file selected, any way to make ti include them all?

If you are talking about your Javascript code, I can't help. I never learned Javascript. If you are talking about KM, then tell me what filter you are talking about. I don't see a filter. All I see is a Prompt action and a Type action.

If your Javascript code is intended to get the names of the selected files, and that code isn't working, why not try the very easy method that KM provides you:

This code will place all the names of all the selected files into a variable. But for me this is about 25 times easier to understand than Javascript. Make sure you include a carriage return after the variable name in this example.

Ah, now I see what you were trying to do with the loop. Yes, for this, you do need the For Each action. Basically, the only steps you were missing were appending the filter results to a new variable, and putting the prompt in its own action after the loop rather than inside it. I believe this should do the trick:

21)Trash It 1.2.kmmacros (32.0 KB)
image

@Sleepy
The OP can't use that method (which I also personally prefer) because he's trying to do this with Path Finder. I know almost nothing about JavaScript too, but that purpose is explicitly written in the script's comments:

20%20PM

1 Like

I try to be brave and help people even when they are talking about things that I don't know much about. Sometimes it works, sometimes it doesn't. In this case (if) the requirement was to get KM to work with his Javascript code - then I'm out of my league here.

YOU ROCK!

My project for the day is to make this same workflow but for Finder!

You are awesome thank you so much!

1 Like

GG is one of the elites here, I'm glad he could help. I'm sorry my advice wasn't as good as his. My name is "Sleepy" for a reason: I'm not as sharp as the experts here.

Trying to do the same thing for Selections in the Finder.

I am having 2 small issues

  1. a " , (Insert File Name) keeps appearing int he prompt even with the filer

  2. Its only displaying 1 file again.

I am SURE I am missing something silly but Ive been pulling my hair out for like 2 hours trying to figure this out.

Delete Item FInder Scratch.kmmacros (25.3 KB)

No problem. For the Finder, you don't need a script to get a list of every file path selected. KM's Finder Selection collection can be used directly with the For Each loop without any extra steps. All you need to do is erase or disable the script action here and change the For Each collection to "Finder's selection":

Delete Item Finder Scratch 1.1.kmmacros (22.4 KB)
image

27%20AM

1 Like

wow you are the best THANK YOU

2 Likes

@Brian_Martin, If one of the above posts solves your problem/question as originally stated, please check the "Solved" checkbox (click for details) at the bottom of that post.

Otherwise, please post your remaining questions/issues about this problem.
If you have other questions, please start a new topic.

1 Like