以下代码没有考虑特殊字符的情况,所取分隔符为每行最后一个(考虑了一行有10个以内相同分隔符的情况),楼主先测试吧:- @echo off&setlocal enabledelayedexpansion
- set /p zx=请输入最小字符数:
- set /p zf=请输入分隔符:
- set /a n+=1
- for /f "delims=" %%a in (a.txt) do (
- set "str=!var!%%a"&set /a min=0,pin=8190&set "var="
- for /l %%a in (1,1,14) do (
- for %%a in (!pin!) do (
- if "!str:~%%a!" equ "" (
- set /a max=pin
- ) else (
- set /a min=pin
- )
- set /a "pin=(max+min),y=pin%%2,pin=pin/2+y"
- )
- )
- set /a num+=pin
- if !num! geq %zx% (
- if "!str:%zf%=!" neq "!str!" (
- set "var=!str!"
- for /l %%a in (1,1,10) do set "var=!var:*%zf%=!"
- )
- )
- if defined var (
- for %%a in (!var!) do echo !str:%%a=!>>!n!.txt
- set /a n+=1,num=0
- ) else (
- echo !str!>>!n!.txt
- )
- )
- echo 搞定。&pause>nul
复制代码
[ 本帖最后由 batman 于 2011-2-27 15:47 编辑 ] |