Articles

How to remove End-of-line chars from a .TXT?

August 16, 2010 at 05:39:02
Specs: DOS, 286

Hi!

how can I remove EOL characters from a text file?

I have a text file containing multiple lines, I wish that all lines appear as one line.
Do you know any DOS tool to remove the EOL characters?

example:
the
little
fox
jumps
becomes:
The littel fox jumps

Thank you!


See More: How to remove End-of-line chars from a .TXT?

Report •


#1
August 20, 2010 at 22:28:54

download coreutils for windows then do this

tr "\r\n" " " < file >newfile

GNU win32 packages | Gawk


Report •

#2
August 21, 2010 at 19:45:08

If you don't have permissions to download you can try the following batch code. Note that the maximum individual environment variable length is stated as 8192 bytes (http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true) so if you want to work with files larger than this an alternative is required, perhaps VBScript.

@echo off
cls
setlocal enabledelayedexpansion

set nbr=0
for /f "tokens=*" %%1 in (input.txt) do (
    if !nbr! lss 1 (
    set line=%%1
      ) else (
    set line=!line! %%1
    )
    set /a nbr+=1
)
echo %line%>output.txt
type output.txt
                               

Good luck


Report •

#3
August 23, 2010 at 12:46:06

thanks for your help, but i need a DOS tool for a plain MS-DOS :(

Report •

Related Solutions

#4
August 23, 2010 at 15:30:53

Apologies superturrican2, I didn't pick up on your OS, only excuse is the new forum layout LOL!

In prior posts M2G has recommended the utility Change.com to remove eol chars but that might not now be relevant. Suggest you post your query on the Disk Op System forum and indicate which version of Dos you are using.


Report •

#5
August 23, 2010 at 17:17:53

really? you are still using the very old MS-DOS 6.22+ ??

GNU win32 packages | Gawk


Report •

#6
August 24, 2010 at 07:56:36

@Wahine
Infact I've post this thread on the DOS forum section... however an Administrator move it here in Batch section :P

@ghostdog
I'm doing some work on the old Windows 98, so I need tools for MS-DOS 6/7


Report •

#7
August 24, 2010 at 09:38:48

then you can use the tr tool i mentioned in my post. Its supposed to work on win95 onwards. Pls see the website for more information.

GNU win32 packages | Gawk


Report •


Ask Question