- <# :
- cls&echo off&cd /d "%~dp0"&rem bat存为ANSI/GB2312编码
- powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal \"%~f0\"|out-string|Invoke-Expression"
- pause
- exit
- #>
- $oldfile="Youdict优词英语词源词典(21230条).txt";
- $newfile="结果.txt";
- if(-not (test-path -literal $oldfile)){write-host ('"'+$oldfile+'" 未找到');exit;}
- [System.Collections.ArrayList]$s=@();
- $enc=New-Object System.Text.UTF8Encoding $False;
- $text=[IO.File]::ReadAllLines($oldfile, $enc);
- for($i=0;$I -lt $text.length;$i++){
- $line=$text[$i].trim();
- if($line -eq '中文词源'){
- $word=$text[$i-1].trim();
- $detail=$text[$i+1].trim();
- if($detail -notmatch '^[a-z]'){$detail=$word+' '+$detail;}
- [void]$s.add($detail);
- }
- }
- [IO.File]::WriteAllLines($newfile, $s, $enc);
复制代码
|