Using These 2 Variables How Do I Set Another Variable?

I have variables set:

yy_Var_Name = FolderName
yy_Var_Content = Dropbox

Using these 2 variables how do I do:

SET VARIABLE FolderName = Dropbox


I'm afraid I'm not exactly sure what you mean, but you can set one variable to another variable's contents like this:

And you can similar set a variable to a combination of other variables like this:

The latter of which will give you:

If this doesn't answer your question, please respond with more detail, ideally including

  1. What it is you want to accomplish (i.e. the ultimate purpose of this macro)
  2. The macro in its current state (either as a file or a screenshot, preferably both). See the "How to Post/Upload your Macro" section on the wiki if you're not sure how to do that:

The name of the actual variable I want set is assigned in #1

yy_Var_Name = FolderName -------(#1)
yy_Var_Content = Dropbox

Scenario 1:
yy_Var_Name = FolderName
yy_Var_Content = Dropbox

SET VARIABLE FolderName = Dropbox

Scenario 2:
yy_Var_Name = NEW-FolderName
yy_Var_Content = XYZ

I then need to:

I'm afraid I'm still not following you. When you say

Do you mean something like this:

or like this?

I'll also ask again:

  1. What it is you want to accomplish (i.e. what is the ultimate purpose of this macro)?
  2. Can you show us the macro in its current state (either as a file or a screenshot, preferably both)? See the "How to Post/Upload your Macro" section on the wiki if you're not sure how to do that:

In your example I mean the former.

Okay, great, that’s what I initially thought. But in that case, I’m still not sure what it is you want to know, since I already showed you in my first response how to set one variable to the contents of another, and how to combine two variables into a new one. I hate to sound like a broken record, but if my earlier responses don’t answer your question, it would really help if you shared more details about

  1. What it is you ultimately want to accomplish (i.e. the purpose of this macro)
  2. The macro in its current state (either as a file or a screenshot, preferably both). Again, see the “How to Post/Upload your Macro” section on the wiki if you’re not sure how to do that:

You aren’t getting the point of my question. Can you please see my 2 scenarios described below.

The variable name I want to set is variable. It’s not fixed like usual.

Okay, I think I understand what you mean now. The counter-intuitive trick is to use the %Variable%[VARIABLE NAME]% syntax in the Set Variable field:


This lets you set a variable as the name of another variable. If anything is still unclear, feel free to ask more questions or create a new topic. In the future, it would be very helpful if you provide more details on what you want to accomplish, including posting screenshots, but for now, hopefully this answers your question!

It’s still unclear.

Your third box (with the ORANGE text) indicates it’s an error and won’t actually run.
It doesn’t run when I try it on my KM either.

Can anyone else pass an opinion on my OP and my post #2 please?

I'm aware of the orange text, but in this case, it's not an error; it's more like a warning that there could be an error (at least, that's my understanding of it). Set Variable TO fields expect straight variable names, i.e. without the %Variable%[VARIABLE NAME]% syntax that is needed to use them in standard text fields; it shows up as orange here because that's obviously not what we're doing. By using %Variable%yy_Var_Name% in the third box's Set Variable TO field, we're telling KM to first process the yy_Var_Name variable (which is set to "FolderName" as per the first box) so that it ends up setting the FolderName variable rather than the yy_Var_Name variable. Essentially, when the macro is run, the third box changes from this:

to this:

If you haven't been able to replicate my example, you can try my macro (which I have tested and verified as working) for yourself:

Set Variable to Another Variable.kmmacros (2.7 KB)


Yes, that’s working now. Thanks for your help.

1 Like

That works for fields that expect a variable, but I can't figure out how to do a similar thing in a text field. Specifically, I'd like to set the default value of a Prompt For User Input action to the value of the variable that another variable is pointing to. For instance, if %Variable%PointerVar% = ActualVar, then I'd like the value of %Variable%ActualVar% to show up as the default by evaluating something like %Variable%%Variable%PointerVar%%, but I cant figure out a way to do it. I've tried several different adornments as well as the %Calculate% token. Have you ever done this?

Not in a Prompt for User Input action, but yes. The action you're looking for is the Filter to Value of Named Variable. In your example, you would just need to run PointerVar through that filter before using it in the prompt:


Many thanks. I’d forgotten that filter existed, so that’s useful in its own right.

When you said not in a prompt, did you mean that you hadn’t done it for a prompt, or did you mean it’s not possible (directly) for a prompt?

No problem. I meant I hadn't used it in a prompt for my own personal use case before.