combine multiple lines in text file?

Started by kle2, May 05, 2014, 07:04:32 AM

Previous topic - Next topic

kle2

Hi,

How do I combine multiple lines onto a single line in a text file using Winbatch?

Thanks,
Khoa

JTaylor

You will probably need to expand on your question a bit as it is light on details...but, perhaps the following will be helpful...

You can remove the @CRLF (assuming it is a Windows text file) using StrReplace(lines,@CRLF,"")
You can concatenate using StrCat() or ":" to join the lines.


Jim

kle2

Thanks for your respond Jim!
I am still confused how to do it.  Say I have a Windows text file with 4 lines in it.  I am looking for a way to read the content of a text file (as a whole), and then (combine all 4 lines into 1 line) rewrite them onto an other text file.
Thanks,
khoa

JTaylor

Something like:

txt = FileGet(text_file)
txt = StrReplace(txt,@CRLF," ")
FilePut(new_text_file,txt)

Jim

JTaylor

Note...I put a space at the end to separate the lines....If you don't want a space just adjust the StrReplace() function as needed.

Jim

kle2

Perfect! It is working!
Thanks so much Jim!

Khoa