Home > Net >  jrepl.bat: can't seem to get syntax correct
jrepl.bat: can't seem to get syntax correct

Time:01-16

During the course of a batch file, a path like the following is stored in temp.txt:

c:\folder1\folder2\.

The period at the end is just because the path is generated from a for /r %%a in (.) statement. I try to get rid of this using the world famous jrepl.bat search and replace batch file, escaping the backslash with a double-backslash:

type temp.txt|jrepl "\\." "" >temp2.txt

Only problem is that this produces strange results because the search string is interpreted as a regular expression instead of a literal string. So then I tried this as instructed by the jrepl documentation:

type temp.txt|jrepl "\\." "" /l >temp2.txt

...but then for some reason nothing changes. The trailing \. at the end of the URL unfortunately remains intact. I have no idea what I'm doing wrong...

CodePudding user response:

Just answered my own question. Once I added the /l option, I no longer needed to escape the backslash, so what works ends up being:

type temp.txt|jrepl "\." "" /l >temp2.txt

Almost deleted this whole question but figured maybe 2 more people might encounter this issue over the next 750 years, so what the heck.

  • Related