- @echo off
- set info=互助互利,支付宝扫码头像,感谢赞助
- rem 有问题,可加QQ956535081及时沟通
- title %info%
- cd /d "%~dp0"
- set "input=list.txt"
- set "output1=tmp1.txt"
- set "output2=tmp2.txt"
- powershell -NoProfile -ExecutionPolicy bypass ^
- $dic=New-Object 'System.Collections.Generic.Dictionary[string,int]';^
- $text=[IO.File]::ReadAllLines('%input%',[Text.Encoding]::Default);^
- for($i=0;$i -lt $text.length;$i++){^
- if(-not $dic.ContainsKey($text[$i])){^
- $dic.Add($text[$i],1);^
- }else{^
- $dic[$text[$i]]++;^
- };^
- };^
- $fs1=New-Object System.IO.FileStream('%output1%', [System.IO.FileMode]::Create);^
- $sw1=New-Object System.IO.StreamWriter($fs1, [Text.Encoding]::Default);^
- $fs2=New-Object System.IO.FileStream('%output2%', [System.IO.FileMode]::Create);^
- $sw2=New-Object System.IO.StreamWriter($fs2, [Text.Encoding]::Default);^
- foreach($item in $dic.Keys){^
- $sw1.WriteLine($item);^
- if($dic[$item] -gt 1){$sw2.WriteLine('['+$dic[$item]+']'+$item)};^
- };^
- $sw1.Close();$fs1.Close();^
- $sw2.Close();$fs2.Close();
- echo;%info%
- pause
复制代码
|