As you probably know, you can select multiple files and/or folders in the Mac Finder, and then perform a manual operation on the entire selection, like copy, move, delete, apply tags, etc. If you have an operation that you often perform, then Keyboard Maestro can most likely automate that for you.
Some examples of Keyboard Maestro macros performing operations (actions) on a Finder Selection:
In Keyboard Maestro, you work with the Finder Selection by using the For Each action to iterate over the selected files. For each file in the selection, you can do whatever you would like with the file using the various file actions, including an Execute Script Action. Even if you are writing a macro to operate on only a single item, this is how you get that item.
In the For Each Item Action, you can add one or more of any of the Keyboard Maestro Actions. These Action(s) will be repeated for each file in the selection.
The Finder’s Selection collection sets the For Each Variable to the full path of each file in the selection.
Note the consistency between the first three examples. 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).
To move the files to the Documents folder, you would do this:
To change the Finder Tags, you would use:
You could rename the selected files from .txt to .html like this:
You can pass each file to a shell script using something like this:
This macro will take the selected items in the Finder and perform the following Actions:
BaseFileName-n.extas in “
My Base File Name-1.jpg”
baseFileNamevariable 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.)
See download link for this macro below.