I have a file structured in this way:
What I would like to achieve is replace the lines with \begin{flushleft}, \end{flushleft} and \raggedright with strings of my choice.\begin{flushleft}
The quick brown fox jumps over the lazy dog
\end{flushleft}
\raggedright
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
It is therefore necessary for me to rewrite the file.
Since batch doesn't support more than three statements at a time (if, else if and else), I need a script that determines if the line is the one to replace and replaces it, otherwise write the line intact.
The only way is to the call function. But how do I pass the line under consideration as an argument?
Code: Select all
@echo off
:Variables
set InputFile=merged.tex
set OutputFile=merged-new.tex
:Replace
>"%OutputFile%" (
for /f "usebackq delims=" %%A in ("%InputFile%") do (
call :check %%A
)
)
:check
::echo replace or intacted line
exit /b 0
MOVE %OutputFile% %InputFile%