回复 3# zhangpwr - @echo off
- @setlocal enabledelayedexpansion
-
- set num=0
- set name=0000
-
- :main
- ( for /R %%i in (*.txt) do echo %%i)>files.tmp
- call:fopen files.tmp file
- set /A len=fopen_len-1
- for /L %%i in (0,2,%len%) do (
- set one=%%i
- set /A two=!one!+1
- if !two! LSS %len% call:marge !one! !two!
- )
- pause
- goto:eof
-
- :fopen
- rem %~1 为读取文件名,%~2为储存的变量名
- rem 采用数组的方式储存,不储存换行符
- rem 若无%~2,使用%~n1作为储存的变量名
- set fopen_file=%~1
- if "%~2"=="" (set fopen_vale=%~n1) else (set fopen_vale=%~2)
- set fopen_len=0
- for /F "tokens=1* delims=:" %%i in ('findstr /n .* %fopen_file%') do (
- set %fopen_vale%[!fopen_len!]=%%j
- set /A fopen_len+=1
- )
- goto:eof
-
- :marge
- set /A num+=1
- call:int
- type !file[%~1]! > %name%.txt
- echo=>>%name%.txt
- type !file[%~2]! >> %name%.txt
- echo 已合并!file[%~1]! ^& !file[%~2]!
- goto:eof
-
- :int
- rem 统一格式
- set name=00000%num%
- set name=%name:~-4%
- goto:eof
复制代码 判断500个字符略显复杂,有空我再想想。 |