inserting multiple lines to

November 30, 2009 at 11:48:46
Specs: Windows XP

I'm trying to write a batch file that will automatically insert a series of lines included inside the batch file into any *.plan files in its same directory.

if "<FUNCTIONS_LIST>" can be found in the file, the inserted lines must go directly after that line. If not, then "<FUNCTIONS_LIST>" must be added, then the lines, and then "</FUNCTIONS_LIST>" after the lines.

Can anyone help me do this?

See More: inserting multiple lines to

Report •

November 30, 2009 at 14:09:41
q1: where do you want "<FUNC..." to be placed in the file if it's not already there (beginning, end, somewhere else?)
q2: what is the source of the lines to insert: constants (created in the batchfile) or lines from another file?
anyone who responds will need to know these things i think.

Report •

November 30, 2009 at 14:56:45
The lines to insert will will be written inside the batch file. The idea is to create a batch file that will automatically add certain functions into a uPlan .plan file.

If <FUNC... cannot be found, then all the lines should be inserted on a new line right after "<VARIABLES_LIST/>". If "<VARIABLES_LIST/>" does not exist, then "</VARIABLES_LIST>".

I hadn't provided all the details because I wasn't expecting anyone to code out then entire thing for me, however if anyone wanted to I wouldn't object.

Jason G
Variable Data Services

Report •

November 30, 2009 at 18:45:19
something like this might get you started (not tested, expect some debugging, my code always buggy...)

setlocal enabledelayedexpansion
set line1=<Functions_list>
set line2=<functions_body1>
set line3=<functions_body2>
set line4=</Functions_list>
for /r c:\xx\planfiles %%a in ("*.plan") do (
del temp 2>nul
set flag=0
set /a xx=2
set /a yy=3
set sstr="<Functions_list>"
for /f "tokens=* delims=" %%b in (%%a) do (call :ttt)
if flag equ 0 (
set sstr="<variables_list>"
set /a xx=1
set /a yy+=1
call :ttt)
rem probly need path definition here...
move /y temp %%a)
goto :ex
echo %%b >> temp
:oops... fixed the quotes here
if /i "%%b" equ !sstr! (
set flag=1
for /L %%c in (!xx!,1,!yy!) do (
echo line%%c >> temp)

Report •

Related Solutions

Ask Question