@echo off
for /f %%i in ('sed -n "$=" a.txt') do set number=%%i
:loop
set /a num+=1
set /a n=(%num%-1)*100+1
set /a m=100*%num%
sed "%n%,%m%w a_%num%.txt" a.txt
if %m% LSS %number% goto :loop
[ Last edited by youaoyi on 2008-7-14 at 01:53 AM ]
D:\lxmxn\work\Other>(echo hello,world&echo.this is the second line of the output&echo.cn-dos.net&echo\OK,let's go&echo/Thanks a lot) | split -l 2
D:\lxmxn\work\Other>dir /b x*
xaa
xab
xac
D:\lxmxn\work\Other>type x*
xaa
hello,world
this is the second line of the output
xab
cn-dos.net
OK,let's go
xac
Thanks a lot
D:\lxmxn\work\Other>split --version
split (textutils) 2.1
Written by Torbjorn Granlund and Richard M. Stallman.
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@echo off & setlocal enabledelayedexpansion
set m=1
for /f "delims=" %%a in (a.txt) do (
if !n! GEQ 100 set n=0 & set/a m+=1
echo %%a>>a_!m!.txt
set/a n+=1
)
保留空行
@echo off & setlocal enabledelayedexpansion
set m=1
for /f "delims=" %%a in ('findstr /n .* a.txt') do (
if !n! GEQ 100 set n=0 & set/a m+=1
for /f "tokens=1* delims=:" %%i in ("%%a") do echo.%%j>>a_!m!.txt
set/a n+=1
)