Board logo

标题: 逐行读取文本内容脚本 [打印本页]

作者: 175891641     时间: 2008-12-28 16:12    标题: 逐行读取文本内容脚本

findstr /v /i /n "fff" 视频网址.txt >>2.txt rem 读取上次转换第几行 for /F "tokens=1* delims=:" %%a in ('type nowdownload.ini') do set nowdownload=%%a for /f "tokens=1* delims=:" %%a in (2.txt) do SET MAXURL=%%a if %MAXURL% LSS %nowdownload% goto :finish if %nowdownload% LSS 10 goto :small rem 提取指定行 findstr /i "%nowdownload%:" 2.txt >>b.txt set /a nowdownload=%nowdownload%+1 echo %nowdownload% >nowdownload.ini for /F "tokens=1* delims= " %%a in ('type nowdownload.ini') do echo %%a>nowdownload.ini rem 去除行号 for /F "tokens=1* delims=:" %%a in ('type b.txt') do echo %%b>当前处理网址.txt goto :end :small rem 去处10行以下的文本 for /f "tokens=1* delims=:" %%a in (2.txt) do if %%a LSS 10 echo %%a:%%b>>a.txt rem 提取指定行 findstr /i "%nowdownload%:" a.txt >>3.txt set /a nowdownload=%nowdownload%+1 echo %nowdownload% >nowdownload.ini for /F "tokens=1* delims= " %%a in ('type nowdownload.ini') do echo %%a>nowdownload.ini rem 去除行号 for /F "tokens=1* delims=:" %%a in ('type 3.txt') do echo %%b>当前处理网址.txt :end del 1.txt del 2.txt del 3.txt del a.txt del b.txt exit :finish echo 0 >nowdownload.ini for /F "tokens=1* delims= " %%a in ('type nowdownload.ini') do echo %%a>nowdownload.ini del 1.txt del 2.txt ---------------------------------------------- nowdownload.ini里保存当前的行数 支持1-99行 自己写的脚本

作者: kang2008     时间: 2008-12-28 18:02
如果在MS DOS7.1的环境下,以上的代码无法运行的, 因不支持 for /参数啊, 很的启动盘启动后进入的DOS多是MS DOS7.10的版本

作者: kang2008     时间: 2008-12-28 18:03
如何计算一个文本文件有多少行,并把这个值给一个变量呢???????????

作者: ily2013     时间: 2008-12-28 20:07
Originally posted by kang2008 at 2008-12-28 18:03: 如何计算一个文本文件有多少行,并把这个值给一个变量呢???????????
for /f "tokens=3 delims= " %i in ('find /v /c "" test.txt') do set num=%i

作者: HAT     时间: 2008-12-28 20:33
参考:www.cn-dos.net/forum ... Q: 为方便他人复制,如何给代码加code标签? A: www.cn-dos.net/forum ... 参考:www.cn-dos.net/forum ...