Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I need a batch file to edit a text file.
This file contains test results from a program. The data is separated by spaces and "00000" (space and numbers as delimiter?). I need to have each of them moved to different lines. I also need to have characters "00" inserted at the beginning of each line.
Input (what I have):
123 alpha test 1 00000 223.3Output (what I need):
123 alpha
00 test 1 223.3Can anyone help me, please?
Thanks in advance.

@echo off > newfile
setLocal EnableDelayedExpansionfor /f "tokens=* delims=" %%N in (myfile) do (
call :sub1 %%N
)
goto :eof:sub1
>> newfile echo %1 %2
>> newfile echo 00 %3 %4 %6
goto :eof
=====================================
If at first you don't succeed, you're about average.M2

Apparently I didn't type the sample correctly for the message format. Some of the empty spaces were missing.
Here's the input file (4 lines; 0C - 5, 0RED - 00000, 0YELL - 00000, 0BLUE - 00000):
0C Service [6 spaces] 21 [23 spaces] 0 [9 spaces] 3 [33 spaces] 5 [9 spaces] 5
0RED ACE [16 spaces] 0.5669 [4 spaces] 00000
0YELL ACE [15 spaces] 0.7727 [4 spaces] 00000
0BLUE ACE [15 spaces] 0.1969 [4 spaces] 00000And this is the output file I need (4 lines; 021 - 5, 0T - 00000, 0T - 00000, 0T - 00000):
021 [13 spaces] C SERVICE [16 spaces] 0 [9 spaces] 3 [33 spaces] 4 [9 spaces] 5
0T [2 spaces] RED ACE [3 spaces] 0.0000 [4 spaces] 0.5669 [4 spaces] 00000
0T [2 spaces] YELL ACE [2 spaces] 0.0000 [4 spaces] 0.7727 [4 spaces] 00000
0T [2 spaces] BLUE ACE [2 spaces] 0.0000 [4 spaces] 0.1969 [4 spaces] 00000Mechanix2Go, I really appreciate your help. I tried to modify the batch file you gave, but it just wouldn't let me use all those variables. I found out that the maximum number of variables is 10 (%0 - %9), while I have 19 variables. Also, I couldn't separate the 0s from the C, RED, YELL, BLUE.
Could anyone help me? Sorry about the [spaces], but I need the empty spaces between the variables -- basically I need all the numbers in columns.
Thank you.

You got me mystified.
Maybe you can send me two files, the orig and the needed.
=====================================
If at first you don't succeed, you're about average.M2

Mechanix2Go,
Thank you your prompt response. I will be sending you the two files (input and output).
I really appreciate your help!

Got 'em.
Where does the 0.0000 in the 4th column of lines 2~4 come from?
=====================================
If at first you don't succeed, you're about average.M2

The "T" in the first column of "0T" were to be added because it was not in the input file.
So do the "0.0000" in the third column. They were supposed to be added using the batch file.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |