Renaming a macro (appending a variable)

I have a group of macros that I launch from the menu bar. I would like to update the macros in there with a progress count. When I choose one of these menu bar macros, I can store the name of that macro, and then after that when I run some other macros I want to update the macro name accordingly.

Project X (initial state)
Store 'Project X' as trigger
Do some work ... macro updates the macro to:
Project X [11/24]

All the other macros that do the necessary calcs are fine, I have the progress string built, so how would I rename that macro which I know is named 'Project X' to 'Project X [11/24]'.

You can use AppleScript to rename an existing Macro.

A Macro has both a name and a unique UUID. The UUID remains the same even if the name is changed so, referencing a Macro by its UUID is probably the way to go if you want to rename it several times.

To get a Macro's UUID, right-click on it and choose Copy As>UUID

You will get something like this in the Clipboard:

0D76829A-F274-48C0-8C13-2214BD1C630F

Once you have this unique UUID an AppleScript can rename the Macro to anything you want. And you can keep renaming it as the UUID won't change.

Here is a proof of concept (change the actual UUID in the Magenta Action to a UUID of a Macro you want to test rename).

PROOF OF CONCEPT Rename a Macro.kmmacros (3.8 KB)

Click to Show Image of Macro

4 Likes

That is perfectly clear, so brilliantly explained - I can put this straight to use. Thank you

1 Like

This gave me an idea, and I was able to greatly simplify a few of my macros. Thanks for the info!

1 Like

I have got this working perfectly now. Well, almost perfectly ...

The only issue I am having is that with some of the macros, I use Emoji as a way of helping to identify things. When I rename the macro, theses are getting broken and end up like this:

:cloud: --> )‚òÅ GCP:

My assumption is that AppleScript doesn't like Emojis. Is there anything that I can do to ensure that the emojis are left intact? A quick search for 'AppleScript emojis' seems to indicate that there is not a way around that. But worth asking, just in case ...

I was going to say that this method probably can't work with emojis, but I just ran my original Proof of Concept Macro that I uploaded above and it copes fine with emojis...

Rename Macro with emoji

This is what my Action looks like with the emoji in it:

Thank you for this thread. This was exactly what I needed for my task.
I have been importing many files, statements, etc into DEVONThink.
I have a Tag palette I use for tagging these items with standard tags except
the year changes (Importing years of files).
I have a small script to set a persistent year variable, but no way to easily see the last setting.
Using this method, I update the Macro name using the currently set year.
If the year needs to change, the macro gets user input, updates the variable and changes the Macro name to match.
Now I can quickly see the year that will be used.
Many thanks!

Tag Palette

Regards

1 Like