1

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?

dbenham
  • 127,446
  • 28
  • 251
  • 390

1 Answers1

2

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.

SomethingDark
  • 13,229
  • 5
  • 50
  • 55
  • Thank you very much for your answer! I've just found the same solution of the problem. Anyway, like to you for right realization! – Izya Kurvitch Jul 16 '19 at 20:24