- @echo off
- set "分隔符=zheshifengefu"
- set 分隔符_字数=13
- set "输出目录=qiefen"
-
- if exist "%输出目录%\*.txt" (
- echo 错误:
- echo,
- echo "%输出目录%" 内已经有 .txt 文件,请转移到其他地方!
- echo,
- set /p =按任意键退出. . . <nul
- pause >nul
- exit /b
- )
-
- echo 将分割当前目录名下的 .txt 文件
- echo,
- pause
-
- cls
- set /p =正在分割文件,请稍后. . . <nul
-
- echo 0 > .num
- md "%输出目录%"
-
- for /f "delims=" %%a in ('dir /a:-d /s /b *.txt') do (
- findstr /n .* "%%a" > .tmp
- for /f "delims=" %%b in (.tmp) do (
- set Var=%%b
- for /f %%n in (.num) do set /a n = %%n
- SetLocal EnableDelayedExpansion
- if "!Var:*:=!"=="" (
- if !n! neq 0 echo,>>"!输出目录!\!n!.txt"
- ) else (
- set Var=!Var:*:=!
- if "!Var:~0,%分隔符_字数%!"=="!分隔符!" (
- set /a n += 1
- echo !n!>.num
- set Var=!Var:~%分隔符_字数%!
- )
- echo,!Var!>>"!输出目录!\!n!.txt"
- )
- EndLocal
- )
- )
-
- cls
- del .tmp .num
- echo 文件分割完成!
- echo,
- set /p =按任意键退出. . . <nul
- pause >nul
复制代码
|