DELETE CARRIAGE RETURN from text files

June 25, 2010 at 00:16:28
Specs: Windows XP
I want to check a directorty for text files and from the searched text file i need to delete carraige return.

See More: DELETE CARRIAGE RETURN from text files

Report •

#1
Report •

#2
June 25, 2010 at 10:01:37
If you prefer to "roll your own", vbscript is good material:

dim fso
set fso=createobject("scripting.filesystemobject")
set ff=fso.getfolder(".\")
for each file in ff.files
test=fso.getextensionname(file)
if ucase(test)="TXT" then
xx=fso.getbasename(file)
repl xx
end if
next
wscript.quit
sub repl(xx)
set inp=fso.opentextfile(xx&".txt",1)
set out=fso.createtextfile(xx&".new")
do while not inp.atendofstream
c=inp.read(1)
' the following removes all line-break char.s (disabled)
'if c<>chr(13) and c<>chr(10) then out.write(c)
' the following removes car.ret ONLY (enabled)
if c<>chr(13) then out.write(c)
loop
inp.close
out.close
end sub
'----- end


Report •

#3
June 25, 2010 at 17:35:00
do while not inp.atendofstream
c=inp.read(1)
' the following removes all line-break char.s (disabled)
'if c<>chr(13) and c<>chr(10) then out.write(c)
' the following removes car.ret ONLY (enabled)
if c<>chr(13) then out.write(c)
loop

Do Until inp.AtEndOfStream
  out.Write inp.ReadLine '& Chr(10)
Loop


Report •

Related Solutions

#4
June 25, 2010 at 17:39:30
Nice one! I'm all in favor of brevity and simplicity. :-)
out.write replace(inp.readall,chr(13),"")

out.write replace(inp.readall,chr(13)&chr(10),"")


Report •

#5
August 24, 2010 at 03:09:20
Here is a online tool that can delete carraige return
texthandler.com

Report •

Ask Question