WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: kle2 on May 05, 2014, 07:04:32 AM

Title: combine multiple lines in text file?
Post by: kle2 on May 05, 2014, 07:04:32 AM
Hi,

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

Thanks,
Khoa
Title: Re: combine multiple lines in text file?
Post by: JTaylor on May 05, 2014, 07:16:20 AM
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
Title: Re: combine multiple lines in text file?
Post by: kle2 on May 05, 2014, 07:42:24 AM
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
Title: Re: combine multiple lines in text file?
Post by: JTaylor on May 05, 2014, 08:01:00 AM
Something like:

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

Jim
Title: Re: combine multiple lines in text file?
Post by: JTaylor on May 05, 2014, 08:01:58 AM
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
Title: Re: combine multiple lines in text file?
Post by: kle2 on May 05, 2014, 08:23:08 AM
Perfect! It is working!
Thanks so much Jim!

Khoa