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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How to remove end-of-line in a file

Reply to Message Icon

Name: tekman82
Date: July 16, 2004 at 11:39:35 Pacific
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!



Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: July 16, 2004 at 17:47:07 Pacific
Reply:

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
--------------


0

Response Number 2
Name: Mechanix2Go
Date: July 17, 2004 at 05:58:22 Pacific
Reply:

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


0

Response Number 3
Name: dtech10
Date: July 17, 2004 at 14:40:51 Pacific
Reply:

Hi Mechanix
Thanks for the praise.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: How to remove end-of-line in a file

How do I add text after a line?? www.computing.net/answers/programming/how-do-i-add-text-after-a-line/10869.html

Script to remove lines from a file www.computing.net/answers/programming/script-to-remove-lines-from-a-file/7090.html

To cut and paste a set of lines from a file www.computing.net/answers/programming/to-cut-and-paste-a-set-of-lines-from-a-file/20198.html