本帖最后由 terse 于 2019-9-25 19:14 编辑
P一个- @echo off & setlocal enabledelayedexpansion
- cd /d "E:\数据\"
- for /f "usebackq tokens=*" %%a in ("a.txt") do for %%b in (%%a) do set/a n+=1&set a!n!=%%b
- for /f "usebackq tokens=*" %%a in ("b.txt") do for %%b in (%%a) do set/a m+=1&set b!m!=%%b
- for /l %%i in (1,1,!n!) do (
- set "f="
- for /l %%j in (1,1,!m!) do if not defined f if /i "!a%%i!" == "!b%%j!" set a%%i=&set b%%j=&set f=1
- )
- if !m! gtr !n! set n=!m!
- for /l %%i in (1,1,!n!) do (
- if "!a%%i!" neq "" if "!as!" == "" (set as=!a%%i!) else set as=!as! !a%%i!
- if "!b%%i!" neq "" if "!bs!" == "" (set bs=!b%%i!) else set bs=!bs! !b%%i!
- )
- echo;!as!
- echo;!bs!
- pause
复制代码 少点FOR- @echo off & setlocal enabledelayedexpansion
- cd /d "E:\数据\"
- for /f "usebackq tokens=*" %%a in ("a.txt") do for %%b in (%%a) do set /an+=1&set "a!n!=%%b"
- for /f "usebackq tokens=*" %%a in ("b.txt") do for %%b in (%%a) do (
- set "f="
- for /l %%c in (1,1,!n!) do if not defined f if /i "%%b" == "!a%%c!" set "a%%c="&set "f=1"
- if not defined f if defined bs (set bs=!bs! %%b) else set "bs=%%b"
- )
- for /l %%i in (1,1,!n!) do if defined a%%i if defined as (set as=!as! !a%%i!) else set "as=!a%%i!"
- echo;!as!
- echo;!bs!
- pause
复制代码
|