中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-04 03:37
48,038 topics / 350,123 posts / today 0 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » [Help] How to append the string from a specified line to a file
Printable Version  857 / 2
Floor1 29984365 Posted 2007-04-06 05:57
初级用户 Posts 15 Credits 39
I have a bunch of data text files stored somewhat like this,

Identifier a: 1111 units
There may be N identifiers in between
Identifier b: 222 units
Separator
Identifier c: 333 units
Identifier c: 4444 units
Identifier d: 55 units


Characteristics of the text: identifiers may repeat, the length of each piece of data is not fixed, and the units for each kind may not necessarily be the same.
I want to find the data on the line below Separator in this kind of data text and append it to a file.

My idea is to first determine the line number X of Separator, read line X+1, and extract the needed data. Since I'm a newbie, after reading those posts in the sticky index I'm still kind of confused. The batch file I wrote below is also pretty clumsy, and it still has some problems: for example, if the data length changes, there's no way to record it accurately!




I don't know which expert could help point me in the right direction and optimize this a bit.

[ Last edited by 29984365 on 2007-4-6 at 06:12 PM ]
Floor2 lxmxn Posted 2007-04-06 07:00
版主 Posts 4,938 Credits 11,386

Based on the additional requirements and goal the OP mentioned, I wrote this batch file. OP, give it a try; if it doesn't work, then reply and we can discuss it further.
Floor3 29984365 Posted 2007-04-06 07:12
初级用户 Posts 15 Credits 39
Tested it, works very well.

If processing a lot of files, I guess it will take a long wait =.=
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023