When i write the text
set aSecondString to replaceString(aSecondString, "\\", "\\\\")
to a file (plain text, utf-8), it results in a file containing
set aSecondString to replaceString(aSecondString, "\", "\\")
Saving the same text with BBEdit or TextEditor is ok. Am I missing something?
By default, Keyboard Maestro processes text tokens in text fields, so it's interpreting "\\" as "the user wants an actual backslash, as they've escaped it." (Note: This may be far off from the technically correct description of what's going on, but it's how I think of it and remember it :).)
You just need to disable token processing for that action, using the gear menu:
You should then get what you expect in the output file.
1 Like
Ironically, so does the forum, so when you wrote quote backslash backslash quote it helpfully displayed only one of them! I added two more backslashes to your post so it properly displays both of them, hope that's ok 
1 Like