Macro doesn't recognise some letters?

Text Local Variable.kmmacros (2.4 KB)
Here you go.
If I add "local" to the Finder Selection, it doesn't work.

The problem here is that %FinderSelection% is a token, not a variable. A token is a text string that holds a value—in this case, lines of text representing the Finder's selection.

You can't turn that into a local variable, so sorry for the confusing statement earlier. This is a reason why most of us use %Variable%local_VarName% style whenever we use a variable: It prevents confusion with tokens, which otherwise look identical.

So you can either use it directly as %FinderSelection%, or you can save the value of the token into a variable, and then use the variable:

(Note that FilePath is still a global variable; I didn't change it from your macro.)

The advantage of using a variable is if you were doing something where the token's value could change. This probably isn't an issue with the Finder selection, as you're unlikely to change that while the macro runs, but other tokens, such as those related to windows and the clipboard, certainly can.

-rob.

2 Likes

I'll try to understand all that! :slight_smile: Thanks for the comprehensive response! My main macro still doesn't work though. With or without locals. I don't know why.

Now it works again. I experienced the intermittent problem with that macro today a few times. And I can't debug it as it runs "For Each" as one action with no pause.