Replace text in file using JREPL.BAT

710 Views Asked by At

My batch script is supposed to replace content within a file or list of files, but doesn't work and unfortunately exits cycle loop...

Here the code:

@echo off
setlocal enabledelayedexpansion
set "int=000"
set "int_new=111"
for %%i in ("c:\text.txt") do (
    jrepl "!int!" "!int_new!" /m /f "c:\text.txt" /o "c:\text_2.txt"
)
pause

It replaces the text but exit the script, could you explain where my mistake is?

1

There are 1 best solutions below

1
SomethingDark On BEST ANSWER

Because JREPL is a separate script from your script, when you run JREPL directly like that, the flow of your script transfers to JREPL and terminates when JREPL does.

If you want to come back to your script once the replacement is complete, use call jrepl instead.