It is doing what you're asking.
[tt]
s="c:\\folder1\\file1.txt"; //input
t=s.replace(/\\/g,"\\\\"); //output
alert(s+"\n"+t);
//if you like and that it risks to confuse you more
s="c:\x5cfolder1\x5cfile1.txt"; //input
t=s.replace(/\\/g,"\\\\"); //output
alert(s+"\n"+t);
[/tt]