Change the Name of a Variable in Preferences (Global Variables)

Continuing the discussion from Easy Way to Convert Variables to Local Variables?:

It sounds like this is not doable from other threads but is there a way or @peternlewis in a future update to change the name of a variable and have all macros that use that variable to change their name to the changed Global Preference Variable name.

The second part to that would be if there was a way to list all the macros that use that variable to help clean things up when Global Variables get crazy.

Officially?

Probably will never happen. Ditto for your second question.

This kind of thing is not needed by many of Peter's users, so he's unlikely to invest much time in it. Unfortunately.

(I feel your pain on this one.)

Unofficially / 3rd Party?

It IS possible to parse the entire Keyboard Maestro plist in a text editor (or programmatically) and make global changes, but this is a dangerous procedure that could destroy all of your macros.

@JMichaelTX and @DanThomas have both worked on systems to change variable names around in a single macro.

Some things will be possible in Keyboard Maestro 10 that might facilitate some of these things. We'll have to see when it comes out.

-Chris

2 Likes

Thank you that is very helpful and good to know where things stand since I seem to find new things all the time that I didn't realize existed.

Basically, no.

While it would be relatively straight forward to change the variable name and have it reflected across all actions that use a variable explicitly, it would be much more messy to change it across all text that uses a variable, and nigh on impossible to change it in scripts that use that variable, and entirely impossible to change it in external scripts that use that variable.

So at best Keyboard Maestro could do a partial job, and as a general rule if I can't do the job completely and correctly, then I don't do it at all.

As @ccstone says, you can hack it yourself - indeed if your variable name is sufficiently unique you could quit Keyboard Maestro and Keyboard Maestro Engine, open the Keyboard Maestro Macros.plist in BBEdit, (saving a copy first), then search and replace the variable name and that would probably work fine for most cases.

2 Likes

Okay, that makes sense thanks for the feedback and help.

It makes sense how hairy it can get when AppleScript and other things reference Variables.

1 Like