windows - Replace a line with another line using IF - Batch file -


I'm trying to change a line in load.xml using lines from File.List.txt. Load.xml's content

  & lt; The main part & gt; & Lt; InFilePath & gt; D: \ Data \ All_Inputfiles \ oldfile.txt & lt; / InFilePath & gt; & Lt; / Mainheader & gt;   

file list .txt

  newfile1.txt newfile2.txt   

Expect output with each recurrence < / P>

  & lt; The main part & gt; & Lt; InFilePath & gt; D: \ Data \ All_Inputfiles \ newfile1.txt & lt; / InFilePath & gt; & Lt; / Mainheader & gt;   

and replace the newfile1.txt with newfile2.txt with the next visit. I am able to get the original string with the final string, but the last part of the code is throwing a syntax error, i.e. call for "f" delims = "%% a in! (INTEXTFILE!):" %% a "Change

Please help me? Thanks in advance.

  @echo off SETLOCAL EnableDelayedExpension AllInputFile Set = D: \ Data \ FileList.txt SET INTEXTFILE = C: \ c: \ load.xml Set OUTTEXTFILE = D: \ data \ Tmp_out.txt SET BackupPath = D: \ data \ backupload.xml Set TempFile = D: \ data \ tmp.txt SET DbgFile = D: \ data \ debuginfo.txt Del! TempFile! Dell! DBG file! Copy! INTEXTFILE! ! BackupPath! : Findstr / g instead of "InFilePath"! INTEXTFILE! & Gt ;! TempFile! :: Set string = "& lt; InFilePath & gt; D: \ data \ All_Inputfiles \ oldfile.txt & lt; / InFilePath & gt; Set / P string = & lt; ! Tempfile! Set PREVFILE_NM =! String: ~ 75, -13! Finerplayline = Set! String! Set TARG_FILE =% ~ 1 REM ECHO "Before Changing Last Location"! Change the last place! & Gt; & gt ;! DBG file! FinalLayline = Set! Last location: line:% PREVFILE_NM% =% TARG_FILE%! ECO "string"! String! & Gt; & gt ;! DBG file! ECHO "Final Location Line"! Change the last place! & Gt; & gt ;! DBG file! :: The string in the string is the target string to substitute for the source string and the final placeline / f "delims =" %% a (! INTEXTFILE!): "%% a" exit / b: Change text =% ~ 1 Replace "% text%" == "% string%" ((echo! Last location!) >> !!! OUTTEXTFILE!) And ((echo! Text!) & Gt; & gt; OUTTEXTFILE!) Exit / B    

Is this work for you?:

 < Code> @echo off for / F "usebackq delims =" %% a in ("FileList.txt") (Call: Change "%% a" type "load.xml" break) Echo paused: EOF: change (echo ^ & l T; mainheader ^ & gt; echo ^ ^ inFilePath ^ & gt; D: \ data \ All_Inputfiles \% ~ 1 ^ & lt; / InFilePath ^ & gt; echo ^ ^ & lt; / mainheader ^ & gt; Gt; "Load.xml"    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -