Computing.Net > Forums > Programming > How to remove end-of-line in a file

How to remove end-of-line in a file

Reply to Message Icon

Original Message
Name: tekman82
Date: July 16, 2004 at 11:39:35 Pacific
Subject: How to remove end-of-line in a file
OS: Win 2000
CPU/Ram: 1ghz, 1gb ram
Comment:

I’m trying to making a batch file that replaces a word with another in a file(s!) that containing the word. By using Edlin program.
And to use edlin so req. it ^Z (Ctrl+Z) as a breaker between old text and the new text, but that’s no problem. It’s the end-of-line char that’s the problem when I use echo!

This batch is meant to run on a windows 2000 machine.

Exec:
Batchfile searchfile oldtext newtext

Z file is containing the end-of-file char. (^Z) so I can create the 1Roldtext^Znewtext line to use with edlin.

@echo off
Setlocal
echo %2>tmp #must remove the end-of-line (CR/LR) from this file in order for this to work.
echo %3>tmp1
copy /b tmp + z + tmp1 edlin.rep >Nul
echo E >> edlin.rep #in order to quit edlin.
For /f “” %%a IN (‘dir /s %1 ’) DO For /f “” %%b IN (‘find “%2” %%a’) DO edlin %%b <edlin.rep &del %%b.bak #Not finished...
del tmp&del tmp1&del edlin.rep

Edlin.rep #with end-of-line...
1Roldtext
^Znewtext
E

Must be: then it will work.
1Roldtext^Znewtext
E

And I don’t know how to work with Debug so I’m stuck and I’m out of ideas. Please help me!


Report Offensive Message For Removal

Response Number 1
Name: dtech10
Date: July 16, 2004 at 17:47:07 Pacific
Subject: How to remove end-of-line in a file
Reply: (edit)

This might help, it requires Debug but it's simple to create.
Paste the text below into notepad not the
dividing lines ie ------- and save, name as oneline.txt.
Go to the command prompt and type
debug < oneline.txt to create oneline.com

Use this syntax in you batch file.
It works like echo but there is no CR/LR at the end.

oneline Copy to > temp.txt
echo Filename >> temp.txt

temp.txt now containts "Copy to Filename"
on one line.

n oneline.com
a 100
mov ah,2
mov si,82
mov,dl,[si]
cmp dl,d
jz 113
mov ah,2
int 21
inc si
jmp 105
mov ah,4c
int 21

r cx
17
w
q
--------------


Report Offensive Follow Up For Removal

Response Number 2
Name: Mechanix2Go
Date: July 17, 2004 at 05:58:22 Pacific
Subject: How to remove end-of-line in a file
Reply: (edit)

dtech10,

That's pretty slick

I'm not sure exactly what Saldor needs, but I thought it was to replace one word with another in a file.

If so, I recommend CHANGE.COM from PC Magazine for files up to about 30K, and CHANGE.EXE from Bruce Guthrie for files of any size.

HTH

M2


Report Offensive Follow Up For Removal

Response Number 3
Name: dtech10
Date: July 17, 2004 at 14:40:51 Pacific
Subject: How to remove end-of-line in a file
Reply: (edit)

Hi Mechanix
Thanks for the praise.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: How to remove end-of-line in a file

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software