合并当前目录下所有txt的第一段(以空行区分段落,仅含全角或半角空格的行也做空行处理)
- @echo off
- (for /f "delims=" %%i in ('findstr /n .* *.txt') do (
- set "str=%%i"
- for /f "tokens=1,2* delims=:" %%a in ("%%i") do (
- if not defined .%%a (
- if defined k echo;&set "k="
- set kh=&set .%%a=a&set k=a
- )
- if "%%a:%%b:"=="%%i" set kh=a
- )
- if not defined kh (
- setlocal enabledelayedexpansion
- set str=!str:*:=!
- set str=!str:*:=!
- set str=!str: = !
- set str=!str: =!
- if defined str echo;!str!
- endlocal
- )
-
- ))>tem.txt
- start "" "tem.txt"
复制代码
[ 本帖最后由 随风 于 2011-3-15 08:18 编辑 ] |