What's the best way to duplicate macros using a macro?

I have a palette that i use in my finder with buttons to move files around the place. Each macro looks like this:

The problem is that I keep coming up with other folders that I frequently want to sort things into and so each time I end up going into KM and duplicating a macro and then changing its name and the directory the file goes to and, ideally, the icon.

I'm wondering whether there's an easier. more efficient way of doing this. A button in the palette that says "New Button" that lets me name it, select the directory and then (even) give it an icon though that part's not necessary.

I've taken a look at @DanThomas 's organiser but I got lost. Also just downloaded KMFAM but I couldn't get it to install.

Am I going about this the wrong way?

I've done this sort of thing in the past using a Prompt With List:

Sort into Folder.kmmacros (3.4 KB)

When you come up with a new folder you want to sort into, just add a line to the Prompt With List in this format:

/full/path/to/folder__Display Name in List

You can choose to sort or not sort the list (via the Gear icon), so you could put often-used folders near the top. And because it works with predictive typing, you could do things like 1-Desktop, 2-Documents, etc. to let you choose a folder with a single numeric key.

Maybe not what you're looking for, but I love using Prompt With List for its flexibility and zero mouse interaction.


1 Like

Yeah that's not a bad shout actually. I sort of do like having buttons but for this sort of thing where I keep adding ones and they keep shifting around a list and just keyboard input is probably better!

I think @griffman's solution is the best solution for your situation. But you also asked about how to make a Macro Making Macro (as a kind of template). Here's an example that would make Macros like the one you have in your question.

Screen Recording 2023-12-31 at 16.27.58-Animated GIFF 640 12fps

And this is the example Macro Making Macro used for the video above. It is set up so that if you select a folder in the Finder and run the Macro, that folder will be used as the default path. And the group the Macro is saved in is called "Experiments" but all this can be changed just by you changing the first Magenta Action to the defaults you would like the Prompt to show.

EXAMPLE Macro to Make Macros.kmmacros (6.8 KB)

And a way I have found to make these Macro Making Macros is this:

  1. Make a temporary template Macro which is to be the basis of all the new Macros. I use uppercase letters for any elements that I want to have as "placeholders" to make them easy to find.


  1. Select this Macro in the Macro Column and use Edit>Copy as>Copy as XML to copy the Macro's XML to the clipboard.

  2. Paste this text into any text editing app like TextEdit or Notes:

  1. Replace the "placeholder" text with Variables:

  1. Now paste this edited XML into the appropriate Action:

(At the risk of adding confusion - one thing to watch is if any %s need to be retained as literal %s in the new Macro that will be created, you need to double quote them).

In the example I uploaded, a new Macro will be created with its Group, Macro Name, and the Path set by you but the beauty of this technique is that just about anything can be customised.

You could also automate more, for example making the default name of the newly created Macro the name of the folder you have selected in the Finder. Basically any text you can get into a Variable can be used.


Wow thank you so much @Zabadon always so chuffed by how supportive this community is.

Going to devour this tomorrow.
However, one thing I've noticed with @griffman 's solution is that when I press the wrong button (sending it to the wrong directory accidentally) the finder doesn't respond to cmd-z. Is there any way to work around this? It's a bit maddening since I then have to remember what mistake it was I made (hard given that I didn't notice I was doing it until it was too late)

1 Like

Did your "dupe the macro" method allow undo in Finder? Both macros use the same Move action, so if it worked in one, I think it'd work in the other.


Lemme check.
I will say though you're completely right about it being easier than buttons. I don't know what I was thinking.

It would be theoretically feasible to make an "Undo" macro: When you invoke the first macro, it would save the file list, source directory, and destination directory to global variables. An Undo macro would read those variables and reverse the move, then delete the global variables.