本帖最后由 apang 于 2013-3-23 19:30 编辑
- @echo off&setlocal enabledelayedexpansion
- set /a s=1,m=1
- for /f "delims=" %%a in (a.txt) do (
- set /a "n+=1,1/(n-21)" 2>nul||set /a n=1,m+=1
- if !m!==47 set /a s+=1,m=1
- md !s! 2>nul
- echo,%%a>>!s!\!m!.txt
- )
- pause
复制代码 vbs,速度比bat快很多。实测10000行文本,vbs用时4秒5,bat用时12秒8- Set FSO = CreateObject("Scripting.FileSystemObject")
- Set File = FSO.OpenTextFile("a.txt",1)
- s = 1 : m = 1
- Do Until File.atEndOfStream
- Str = File.ReadLine
- n = n + 1
- If n = 21 Then m = m + 1 : n = 1
- If m = 47 Then s = s + 1 : m = 1
- If Not FSO.FolderExists(s) Then FSO.CreateFolder(s)
- FSO.OpenTextFile(s & "\" & m & ".txt",8,True).WriteLine Str
- Loop
-
- MsgBox "OK"
复制代码
|