[SOLVED] Can't replace %26 no matter what

I'm trying to use Search and Replace to replace %26 in a path, but it isn't working. It removes the % and keeps the 26

I tried using the String option:

Regex like this

And like this:

Try doubling the percent sign, I suspect it looks like the start of a token to KM.

Didn't work either.
I have another action like this to replace %20 and it works:

Same for %2F

End result

Create index files for Obsidian Macro (v11.0.1)

Create index files for Obsidian.kmmacros (23 KB)

Keyboard Maestro Export

Works here:

It seems like you're trying to percent decode. Have you tried using the “percent decode URL” Filter action?

1 Like

My issue is with %26 only.
The %2F and %20 work as expected

This helps with having 1 action to replace both %20 and %2F, but for some odd reason, I still get the number 26 on my path...
Can you please check if you get the same result using my macro?

Create index files for Obsidian.kmmacros (22 KB)

Keyboard Maestro Export

Ok I found the issue, with the help of what @RogerB said.

When you look at the preview, it's assuming that %20% is a global variable, so it removes it completely. That makes the % from %26 to be gone. When I try to replace %26, it's not there, only 26. The second %20 is kept, because there's no % after it.

By doubling the % before the first %20 and then before %26, the preview shows everything.

In this case I can even skip the doubling of %26, because when it's single, it actually shows me the original & that's on the original path:

Actually, I can't skip the double % before 26, because then it removes the % before the next 20, so when I replace all %20 with a space, it keeps the 20 after the %26.

Final macro:
Keyboard Maestro Export


1 Like

I believe you have to double all the percent symbols, otherwise they get interpreted as tokens. As a test, I did this to your macro:

You'd think the output would be the same as the input, but it's not:

Original Path:
obsidian://open?vault=Tiago&file=Apps 26%20Plugins%2FKeyboard%20Maestro%2FSubroutine

You can see the first %20 is gone, and the % before 26 is missing—and that's why your search fails. If you double all the percentage signs in the Set Variable, then it works:

Original Path:

Fixed Path:
~/Library/Mobile Documents/iCloud~md~obsidian/Documents/Tiago/Apps & Plugins/Keyboard Maestro/Subroutine

I'm guessing this is due to text tokens, but can't fully explain it beyond saying that :).


1 Like

I think you were writing while I was adding my previous reply.

Basically, the way I interpret it is that it sees %20% as a global variable. Since that variable is not set, it replaces it with an empty space. So %20%26 becomes just space26.

I would expect the "global variable" 20 to be replaced with "nothing" instead of an empty space so I would expect it to be 26 and instead of space26.
I don't know if that's normal or not, but it seems to be how it is.
Once I doubled the first % and the one before %26, it worked.

1 Like

Sorry. Same answer, though.

But my question here is:
Are you just trying to replace %26 with a macro that only has that?
In this case, the context of my macro (as explained above) is very important.

The issue is not just the replacement of %26.
Check the replies and you will understand what I mean.
It seems that KM is interpreting certain things as variables such as %20%
So when I have %20%26, it sees %20% as a variable and that leaves me with just 26, not %26. That's why replacing %26 doesn't work, because it's not there.

Again, the context of the macro is relevant in this case.