- <# :
- cls
- @echo off
- cd /d "%~dp0"
- powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default))) -Args '%~dp0'"
- pause
- exit
- #>
- $path=$args[0].trimend('\');
- $file1=$path+'\a.txt';
- $file2=$path+'\tmp.txt';
- $file3=$path+'\b.txt';
- if(-not (test-path -liter $file1)){Write-host ('"'+$file1+'" not found');exit;};
- if(-not (test-path -liter $file2)){Write-host ('"'+$file2+'" not found');exit;};
- $arr=New-Object -TypeName System.Collections.ArrayList;
- $enc=$Utf8NoBom=New-Object System.Text.UTF8Encoding $False;
- $text1=[IO.File]::ReadAllLines($file1, $enc);
- for($i=0;$i -lt $text1.count;$i++){
- $brr=$text1[$i] -split '[\t]+'
- [void]$arr.add($brr);
- };
- $fs=New-Object System.IO.FileStream($file3, [System.IO.FileMode]::Create);
- $sw=New-Object System.IO.StreamWriter($fs, $enc);
- $text2=[IO.File]::ReadAllLines($file2, $enc);
- for($i=0;$i -lt $text2.count;$i++){
- for($j=0;$j -lt $arr.count;$j++){
- $n=0;
- for($k=0;$k -lt $arr[$j].count;$k++){
- if($text2[$i].contains($arr[$j][$k])){$n++};
- };
- if($n -eq $arr[$j].count){
- $tmpline=($arr[$j] -join '\')+"`t"+$text2[$i];
- $sw.WriteLine($tmpline);
- $sw.Flush();
- break;
- };
- };
- };
- $sw.Close();
- $fs.Close();
复制代码
|