Ok, so I have two files which contain identical text with the exception of one line, what I'm doing is copying the differing line from the %source%
file to the %target%
file (which in essence is just writing the whole file line by line to the new file). The problem I'm having is that occasionally the source file will have an in-line comment denoted by an ! which does not translate to the target file. The code I am currently running is as follows:
setlocal EnableDelayedExpansion
(
for /F "tokens=1* delims=:" %%a in ('findstr /N "^" %source%') do (
set "line=%%b"
if defined line set "line=!line:%replace%=%replaced%!"
echo(!line!
)
) > %target%
endlocal
goto :eof
For ease the source file is a simple text file as is the target file. Tried a couple of the other "get around !" problems with delayed expansion but cannot seem to find one that works well for this situation as I don't know where in the file the ! will occur. I've tried moving the setlocal/endlocal into the for loop as well but that doesn't seem to work either.
The format of any given line in the %source%
file that would cause a problem would be:
JARG 0.1000 1.2000
LINE 0.5000 1.0000 !This line tells us what is in the line
SMAP 0.0000 1.1100
Thanks for any help.