Someone, please help ... oh, I will be so grateful. I have a very long batch file that works fine, except that every time the user enters input, it replaces the lines in the desired files, BUT it deletes! S in the files, causing problems due to the fact that they are XML configuration files, and they are commented out which should remain. I wonβt insert all the code here unless requested, but in the walnut shell the user enters certain inputs and then runs the batch file ... here is part of the code for one file .... the user enters the installation letter and bdi server name into the drive . I want user input to replace% drive% and% bdi1% .... what it does .... but I DO NOT want it to replace commented partitions ... ie ::
<!-- Tcp message preamble and postamble are flags that mark the beginning and end of an HL7 message. turns into <-- Tcp message preamble and postamble are flags that mark the beginning and end of an HL7 message.
notice without!
here is my code ... what i need to do to stop it! I tried looking here and I thought that I was well on the road with Jeb's answers, but I could not get him to work. thank you in advance
if exist newfile.txt del newfile.txt
for /F "usebackq delims=" %%a in ("%drive%:\mckesson\%bdi1%\importer.config") do (
set str=%%a
set str=!str:server_name=%server%!
echo !str! >> newfile.txt
)
del importer.config
rename newfile.txt importer.config
if exist newfile.txt del newfile.txt
for /F "usebackq delims=" %%a in ("%drive%:\mckesson\%bdi1%\importer.config") do (
set str=%%a
set str=!str:bdi_name=%bdi1%!
echo !str! >> newfile.txt
)
del importer.config
rename newfile.txt importer.config
if exist newfile.txt del newfile.txt
for /F "usebackq delims=" %%a in ("%drive%:\mckesson\%bdi1%\importer.config") do (
set str=%%a
set str=!str:share_name=%share%$!
echo !str! >> newfile.txt
)
del importer.config
rename newfile.txt importer.config
if exist newfile.txt del newfile.txt
for /F "usebackq delims=" %%a in ("%drive%:\mckesson\%bdi1%\importer.config") do (
set str=%%a
set str=!str:drive_bdi=%drive%!
echo !str! >> newfile.txt
)
del importer.config
rename newfile.txt importer.config
source
share