loop works (almost) but I need "nested" output
Posted: 29 May 2008 14:48
I hope I phrased that right. This is my fist post; please be gentle.
I'm using a for loop to read one line at a time in my source text file, then using that data to create an xml file. I'm having trouble with blank spaces, and/or indenting, and the equals sign.
Here's an example of a few lines from the source text file:
And I get those values with for /F %%T in (%file1%) do...
And here's What I'm trying to get for each line in the text file:
Here's a bit of the batch:
This generates a line for Time, a line for "%%T", a line for Value, a line for "%%T", etc. Also, I'm losing the "=" and I can't seem to get the "nested" look where <Marker is indented two spaces, and Time, Value, etc are indented four spaces.
Here's a bit of what the target should look like:
Thanks!
I'm using a for loop to read one line at a time in my source text file, then using that data to create an xml file. I'm having trouble with blank spaces, and/or indenting, and the equals sign.
Here's an example of a few lines from the source text file:
Code: Select all
00:05:20.346
00:07:22:510
00:08:32.284
And I get those values with for /F %%T in (%file1%) do...
And here's What I'm trying to get for each line in the text file:
Code: Select all
<Markers>
<Marker
Time="%%T"
Value="%%T"
GenerateKeyframe="True"
GenerateThumbnail="False" />
Here's a bit of the batch:
Code: Select all
[snip]
:: start the "nest"
echo ^<Markers^> >> %file3%
:: do the rest
for /F %%T in (%file1%) do (
for %%A in (
^<Marker
Time="%%T"
Value="%%T"
GenerateKeyFrame="True"
GenerateThumbnail="False" ^/^>
) do echo %%A >> %file3%
)
echo ^<^/Markers^> >> %file3%
[snip]
This generates a line for Time, a line for "%%T", a line for Value, a line for "%%T", etc. Also, I'm losing the "=" and I can't seem to get the "nested" look where <Marker is indented two spaces, and Time, Value, etc are indented four spaces.
Here's a bit of what the target should look like:
Code: Select all
<Markers>
<Marker
Time="00:03:07.687"
Value="00:03:07.687"
GenerateKeyFrame="True"
GenerateThumbnail="False" />
<Marker
Time="00:07:28.573"
Value="00:07:28.573"
GenerateKeyFrame="True"
GenerateThumbnail="False" />
[snip]
</Markers>
Thanks!