User Tools

Site Tools


collection:Finders_Selection

**This is an old revision of the document!**

The Finder’s Selection collection contains the paths of each selected item in the Finder.

In Keyboard Maestro, you work with the Finder Selection by using the For Each action to iterate over the selected files. From there, you can do whatever you would like with the files using the various file actions, or by processing with a script or other means. Even if you are writing a macro to operate on only a single item, this is how you get that item. There is a smart action in the acton selector for For Each Path in the Finder Selection, which is simply a For Each action, preset to iterate through the Finder Selection collection. You can put whatever actions you like within that action.

Here are some examples. Set the Finder Label to Red (using the Plug In action for Set the Finder Label).

To change the Finder Tags, you would use:

To move the files to the Documents folder, you would do this:

Note the consistency between them. And note that you could do all three in a single For Each action if you wanted (you would have to ensure the Move was done last of course, as that will change the path to the file).

You can pass each file to a shell script using something like this:

There is a forum topic on working with the Finder selection.

Putting Things Together

This macro will take the selected items in the Finder and rename them using the text in the baseFileName variable and adding a hyphen and a sequential number to it.

The file extension will be retained. (A folder or a file with NO file extension will end up with a '.' at the end of the item-name, but I'll fix that soon.)

finder_rename_and_sequentially_number_selected_items.kmmacros

collection/Finders_Selection.1450823702.txt.gz · Last modified: 2015/12/22 17:35 by ccstone