for /f Question

February 16, 2010 at 15:58:31
Specs: Windows XP
Hello, I searched this forum, found one similar issue, but couldn't find solution. Here is batch file.
@echo off

for /F "tokens=5,10,15,20,25,30,35,40 delims=<>" %%g in (report.xml) do (
echo %%g %%h %%i %%j %%k %%l %%m %%n >>report.log
I am able to get value for %%g thru %%l, but %%m and %%n, both are blank, is there limitations? is there any work around?
Thank you.

See More: for /f Question

Report •

February 16, 2010 at 17:24:27
prob'ly help a lot if you can post a couple of lines of the xml file (esp. any lines that are coming up deficient in your output).
the limits on no. of var.s should not be affecting your script.

Report •

February 16, 2010 at 17:49:27
thank you for quick reply, here is my xml
<?xml version="1.0"?>
<myReport><ReqForm><field id="jobname" taborder="1"><field_value>789456 JobName</field_value></field><field id="customer" taborder="2"><field_value>mySupport</field_value></field><field id="prejob" taborder="3"><field_value>prejob</field_value></field><field id="name" taborder="4"><field_value>myuser</field_value></field><field id="email" taborder="5"><field_value></field_value></field><field id="subject" taborder="6"><field_value>Job Creation</field_value></field><field id="destination" taborder="7"><field_value>Orange</field_value></field><field id="feedback" taborder="8"><field_value>Hello</field_value></field></ReqForm></myReport>
Thanks again!

Report •

February 16, 2010 at 18:25:48
For loops max out at 31 tokens, it can be worked around
by nesting loops:

for /F "tokens=5,10,15,20,25,30,* delims=<>" %%g in (report.xml) do (
    rem "< " is to ensure the second loop is always executed
    rem even if %%m is empty
    for /f "tokens=5,10 delims=<>" %%n in ("%%m< ") do (
        >>report.log echo %%g %%h %%i %%j %%k %%l %%n %%o

Report •

Related Solutions

February 16, 2010 at 18:51:19
Hi Judago,

Thank you for clear explanation, and script worked like a charm.

Report •

Ask Question