- @echo off&setlocal enabledelayedexpansion
- for %%a in (*.txt) do (
- set "a=%%~na"
- if "!a:~14,1!"=="1" if exist "!a:~0,14!2.txt" if not exist "!a:~0,13!.txt" (
- call:a "!a:~0,14!" "!a:~0,13!" 1
- call:a "!a:~0,14!" "!a:~0,13!" 2
- ))
- exit
- :a
- (for /f "usebackq delims=" %%b in ("%~1%3.txt") do (
- set "b=%%b"
- set "b=!b:|=!"
- set "b=!b: =!"
- set "b=!b: =!"
- echo !b!
- ))>>"%~2.txt"
复制代码 1,set "b=!b: =!"中为制表符
2,分别删除管道、空格、制表符,楼主可以根据自己需要选择
3, if not exist "!a:~0,13!.txt" 为防止重复合并,楼主可以根据需要选用
4,如果合并后要删除源文件,则:- @echo off&setlocal enabledelayedexpansion
- for %%a in (*.txt) do (
- set "a=%%~na"
- if "!a:~14,1!"=="2" if not exist "!a:~0,13!.txt" (
- call:a "!a:~0,14!" "!a:~0,13!" 1
- call:a "!a:~0,14!" "!a:~0,13!" 2
- del "%%a"
- del "!a:~0,14!1.txt"
- ))
- exit
- :a
- (for /f "usebackq delims=" %%b in ("%~1%3.txt") do (
- set "b=%%b"
- set "b=!b:|=!"
- set "b=!b: =!"
- set "b=!b: =!"
- echo !b!
- ))>>"%~2.txt"
复制代码
[ 本帖最后由 hanyeguxing 于 2011-1-23 16:33 编辑 ] |