Although I cannot help you solve the problem that occurs when using the repl.bat file, I can offer another way to solve the original problem of replacing the path.
If the jboss7 line jboss7 guaranteed to be present in all source paths in your configuration files, you can try the following approach:
@ECHO OFF SETLOCAL DisableDelayedExpansion FOR /F "delims=" %%A IN ('DIR /B /SC:\tintin.txt') DO (CD /D "%%~dpA" & CALL :got1) FOR /F "delims=" %%A IN ('DIR /B /SD:\tintin.txt') DO (CD /D "%%~dpA" & CALL :got1) GOTO :EOF :got1 SET "propfile=%CD%\standalone\configuration\logging.properties" IF NOT EXIST "%propfile%" GOTO :EOF SET "tempfile=%TEMP%\logging.properties.tmp" FIND /I /V "jboss7\\" >"%tempfile%" >>"%tempfile%" ( FOR /F "tokens=1,* delims=" %%I IN ('FIND /I "jboss7\\"') DO ( SET "pathname=%%J" SETLOCAL EnableDelayedExpansion IF NOT "!pathname!" == "!pathname:*jboss7\\=!" ( SET "pathname=%__CD__:\=\\%!pathname:*jboss7\\=!" ) ECHO %%I=!pathname! ENDLOCAL ) ) ECHO Old file "%propfile%": TYPE "%propfile%" ECHO ======================================= ECHO New file: TYPE "%tempfile%" PAUSE :: uncomment the next line once you have verified the replacement works correctly ::MOVE "%tempfile%" "%propfile%"
The search for the tintin.txt file tintin.txt been slightly modified to speed up the process. Instead of iterating over all directories and checking to see if it contains a file, the loops now read the DIR output, which returns only existing entries.
Please note that you can also use the FOR /R loop, as in your current code, with the same effect, i.e. return only existing paths, but only the mask should be specified in the IN clause, not the usual name, but it should be a mask that cannot match anything else on your system than just tintin.txt . For example, if you knew for sure that there could not be a file named tintin.txt1 or tintin.txtx or anything else where exactly one character follows tintin.txt , you can use the following pattern instead:
FOR /R "C:\" %%A IN (tintin.txt?) DO (CD /D "%%~dpA" & CALL :got1)
as well as for D:\ . This will only return links to actually existing files and the corresponding mask.
In addition, you can see that the loops do not jump ( GOTO ) to the got1 label, but instead call the got1 subroutine. With this change, you can process multiple application instances at a time. I do not know that yours can be installed several times. If not, you probably want to change it to GOTO .
The subroutine in my script references the configuration file using the full path specified in your description ( ...\standalone\configuration\logging.properties ). For some reason, in your script, the file is referenced simply by its name, even if there is no previous CD or PUSHD command that changes the current directory to the file location. I suggested that you try to simplify your script and miss this bit, intentionally or not. Otherwise, I might have missed something in your explanation and / or script.
After verifying that the configuration file exists in the expected location, the replacement itself is performed as follows:
All configuration lines without a path are written to a temporary file at a time.
Each configuration line containing a path is processed as follows:
if it does not contain the string jboss7\\ , it is omitted;
otherwise, part of the path to and including jboss7\\ ;
the current directory is inserted before the rest (after replacing each \ with \\ );
the new value is returned to the configuration line;
The update line is added to the same temporary file.
In the old version, the configuration file is replaced with a new one.
Obviously, the script can reorder the lines in the processed file, but it is assumed that it does not matter.