代码如下,请先测试。 target和num里面的内容可以换成自己需要的。。。(又:988行的文件,按200行分,最后一个应该是188,不是198???)
@echo off & setlocal enabledelayedexpansion
set "target=123.txt"
set /a "num=200"
set /a "line=0"
set /a "file_index=1"
for %%a in (%target%) do (
set file=%%~na
set ext=%%~xa
)
:_loop
set "tempfile={{%random%}}.{{%random%}}.~tmp"
if exist "tempfile" goto _loop
break>%tempfile%
for /f "tokens=*" %%a in (%target%) do (
set /a "line+=1"
echo %%a>>%tempfile%
if "!line!"=="%num%" (
copy /y "%tempfile%" "%file%_!line!_!file_index!%ext%" >nul 2>&1
break>%tempfile%
set /a "file_index+=1"
set /a "line=0"
)
)
copy /y "%tempfile%" "%file%_!line!_!file_index!%ext%" >nul 2>&1
:end
del /f /q "%tempfile%" >nul 2>&1
endlocal & @echo on
运行结果:
@echo off & setlocal Enabledelayedexpansion
CD /d %~dp0
set x=100000
set xh=1
For /f %%i in (s1.txt) do (
echo %%i>>切分文件\stup!xh!_!i!.txt
set /a s + = 1
echo !s! %%i !x!
If !s! EQU !x! (
set /a x + = 100000
set /a xh + = 1
echo !x! !xh!
cls
)
)
这样岂不是更简单而且更快为什么要搞得那么复杂,谁有更快的!!!!