| | | | | | | | | | | | | $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);COPY |
|