本帖最后由 zaqmlp 于 2019-6-29 23:37 编辑
- @echo off
- set info=互助互利,支付宝扫码头像,感谢赞助
- rem 有问题,可加QQ956535081及时沟通
- title %info%
- cd /d "%~dp0"
- set "file1=a.txt"
- set "file2=b.txt"
- powershell -NoProfile -ExecutionPolicy bypass ^
- $t1=[IO.File]::ReadAllLines('%file1%',[Text.Encoding]::Default);^
- $t2=[IO.File]::ReadAllLines('%file2%',[Text.Encoding]::Default);^
- $text=$t1+$t2;^
- $list=New-Object 'System.Collections.Generic.Dictionary[string,string]';^
- for($i=0;$i -lt $text.length;$i++){^
- $line=$text[$i].trimend().split('^|');^
- $s=$line[0]+'^|'+$line[1]+'^|'+$line[2];^
- if(-not $list.ContainsKey($s)){^
- $list.add($s,$line[3]);^
- }else{^
- $list[$s]=$line[3];^
- };^
- };^
- $fs=New-Object System.IO.FileStream('结果.txt', [System.IO.FileMode]::Create);^
- $sw=New-Object System.IO.StreamWriter($fs, [Text.Encoding]::Default);^
- foreach($item in $list.keys){^
- $line=$item+'^|'+$list[$item];^
- if($list[$item] -notmatch '^^\s*$'){^
- $sw.WriteLine($line);^
- $sw.Flush();^
- };^
- };^
- $sw.Close();^
- $fs.Close();
- echo;%info%
- pause
复制代码
|