|
jmzhwf
新手上路
积分 16
发帖 11
注册 2009-2-4
状态 离线
|
『楼 主』:
[求助]如何对文本进行分段处理?
如一个文本文件含有大量的:$12,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,(内容不定)
如何指定字符数进行分段,如:
$23,$32,$23,$32,$23,$32,$23,$32,
$23,$32,$23,$32,$23,$32,$23,$32,
$23,$32,$23,$32,$23,$32,$23,$32,
$23,$32,$23,$32,$23,$32,$23,$32,
$23,$32,$23,$32,$23,$32,$23,$32,
$23,$32,$23,$32,$23,$32,$23,$32,
$23,$32,$23,$32,$23,$32,$23,$32,
$23,$32,$23,$32,$23,$32,$23,$32,
$23,$32,$23,$32,$23,$32,$23,$32,
|
|
2009-2-19 14:48 |
|
|
zhengqian529
初级用户
积分 100
发帖 93
注册 2009-1-14 来自 湖南
状态 离线
|
『第
2 楼』:
设置一个计数器N,n从0开始计数,
1. 以“,”为分界符,for /f "delims=," %%i in (a.txt) do (set /a n+=1
2. 如果n<8, 执行set var=%var%,%%i. 如果n=8,执行echo %var%,%%i>>b.txt,然后n重新归0
3.到达文件末尾,跳出循环,再执行一次echo %var%,%%i>>b.txt.
可以了。
|
|
2009-2-19 15:38 |
|
|
moniuming
银牌会员
永远的菜鸟
积分 1335
发帖 574
注册 2007-11-27 来自 广西
状态 离线
|
『第
3 楼』:
@echo off
set str=$12,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,$23,$32,
:agn
set/p=%str:~,32%<nul
echo.
if not "%str:~32%"=="" (set str=%str:~32%&goto :agn)
pause
|
|
2009-2-19 16:58 |
|
|