DOS script to break long line

July 21, 2010 at 11:58:45
Specs: Windows
I have a text file a.txt with long line:


I want to break the long line to a specific number of characters, and saved it to b.txt, such as 5 character each line:


The command line should looks like:

cmd1 a.txt b.txt 5

How to write the dos script? Thanks.

See More: DOS script to break long line

Report •

July 21, 2010 at 12:26:44
need to know how long the line is. (there are limits to batch).

Report •

July 21, 2010 at 12:40:43
the line maybe as long as thousands. we need a split the long line to 100 character each line. Thanks.

Report •

July 21, 2010 at 14:22:00
well, if in doubt, don't rely on batch. vbscript is prob'ly faster anyway:

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f, Msg
Set fso = CreateObject("Scripting.FileSystemObject")
Set g = fso.OpenTextFile("outfile.txt", ForWriting, True)
Set f = fso.OpenTextFile("infile.txt", ForReading)
do while not f.atendofstream
hundred = f.Read(100)

Report •

Related Solutions

July 21, 2010 at 17:31:44
download coreutils for windows, then use the split command

c:\test> split -b 5 file

that's all you need

GNU win32 packages | Gawk

Report •

Ask Question