Board logo

标题: 关于FOR SKIP的用法,请牛人指导 [打印本页]

作者: tongwandou     时间: 2008-7-19 01:24    标题: 关于FOR SKIP的用法,请牛人指导

setlocal enabledelayedexpansion set b=0 set c=0 set d=0 call :3 0 :3 for /f "skip=%1" %%a in (5.txt) do ( echo %%a>>d:\1\!c!.txt && set /a b=!b!+1 if !b! GTR 10 set /a c=!c!+1 && set /a d=!d!+10 && call :3 !d! ELSE GOTO :EOF ) 上面的程序不知道哪出了问题,请高人指导。 我的本意是想将5.txt文件,每十行分割为一个新文件,新文件的名称依次为0.txt,1.txt,2.txt等。但一运行程序就提示说:此时不就有” 请高人指导。

作者: HAT     时间: 2008-7-19 01:41
call :3 0 skip不能设置为0吧,你试试。

作者: tongwandou     时间: 2008-7-19 19:04
设成1也不行。感谢楼上的,大家继续。

作者: HAT     时间: 2008-7-19 19:30
因为你的代码存在逻辑上的bug
@echo off
setlocal enabledelayedexpansion
set b=0
set c=0
set d=0
set /p fstrow=<a.txt
>>c:\test\!c!.txt echo %fstrow%
set /a b=!b!+1
call :3 1
goto :eof

:3
for /f "skip=%1" %%a in (a.txt) do (
  >>c:\test\!c!.txt echo %%a
  set /a b=!b!+1
  if !b! geq 10 (
    set /a c=!c!+1
    set /a d=!d!+10
    set b=0
    call :3 !d!
    goto :eof
  )
)

作者: tongwandou     时间: 2008-7-20 13:07
哈哈,果然高手,感谢了。