bat file to delete 14 first lines and modify

April 7, 2011 at 09:51:35
Specs: Windows XP
I have found this site very helpufull and i was wondering if anyone can help me with this problem
any help will really appreciate it

i have a txt file from my work that looks like:
R

CLIMACELL CLC-L 707
Date: 31.03.2011
Time: 09:01
Program: P2
Sg01:T=23.0[C
t=99:59
F=OFF
L=020%
V=050%
Print. Interval: 05 min


22.0[C 09:01 31.03.
27%
22.3[C 09:06 31.03.
27%

and i want first to delete the first 14 lines and save the new file like this

22.0[C 09:01 31.03.
27%
22.3[C 09:06 31.03.
27%

and then modify the file to this

22.0 09:01 31.03. 27%
22.3 09:06 31.03. 27%

i was wondering if this can be done with batch programming

as always thank in advance!!


See More: bat file to delete 14 first lines and modify

Report •

#1
April 7, 2011 at 18:15:32
Here's a Ruby for Windows command you can use.

C:\work>ruby -ne "print !/%/ ? $_.chomp+\" \" : $_ if $.>14" file
22.0[C 09:01 31.03. 27%
22.3[C 09:06 31.03. 27%



Report •

#2
April 8, 2011 at 02:53:15
Batch script not fully tested:

@echo off>outfile.txt
cls
setlocal enabledelayedexpansion

:: Delete first 14 lines & save new file as Infile1.txt
more +14 infile.txt > infile1.txt

:: Amend Infile1.txt and save output as Outfile.txt
set nbr=0

for /f "tokens=*" %%1 in (infile1.txt) do (
    if !nbr! equ 1 (
    set secnd=%%1&call :doit
    ) else (
    set first=%%1&set first=!first:[C=!&set /a nbr+=1
    )
)

:: Display Outfile.txt 
type outfile.txt
exit /b

:doit
echo !first! !secnd!>>outfile.txt
set nbr=0

Did you Google for an answer before asking the question?


Report •

#3
April 8, 2011 at 03:39:43
first of all thank you both for the quick reply

1. the ruby is not familiar to me and i understand that i have to install ruby installer

2. in the batch programming i cant understand who i will put into my initial txt file, e.g. 1.txt, i run the code given but i get 2 files as you metioned infile1.txt and Outfile.txt

please any help
as always thank you in advance!!!!


Report •

Related Solutions

#4
April 8, 2011 at 03:40:17
sorry not who....how!!!

Report •

#5
April 8, 2011 at 19:00:52
If 1.txt is your original data file change this line:
more +14 infile.txt > infile1.txt

to

more +14 1.txt > infile1.txt

Did you Google for an answer before asking the question?


Report •

#6
April 9, 2011 at 00:06:59
you are just amazing!!!!!

thank you again for the help!!!!


Report •

#7
April 9, 2011 at 01:38:50
Ohhh, my ego just got massaged again, thank you for coming back to report your success. You're most welcome.

Did you Google for an answer before asking the question?


Report •

Ask Question