返回列表 发帖
<# :
cls&echo off&cd /d "%~dp0"&mode con lines=5000
path %SYSTEMROOT%\System32\WindowsPowerShell\v1.0;%path%
set "current=%cd%"
powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression"
pause
exit
#>
$current=($env:current).trimend('\');
$logfile=$current+'\info.txt';
$enc=New-Object System.Text.UTF8Encoding $False;
$fs=New-Object System.IO.FileStream($logfile, [System.IO.FileMode]::Create);
$sw=New-Object System.IO.StreamWriter($fs, $enc);
$reg='[\x21-\x27\x2a-\x3b\x3f-\x7e\x3d]+(\.com|\.cn|\.cc|\.net|\.org|\.top|\.vip)[\x21-\x27\x2a-\x3b\x3f-\x7e\x3d]*';
$folders=@(dir -literal $current|?{$_ -is [System.IO.DirectoryInfo]});
for($i=0;$i -lt $folders.length;$i++){
    write-host $folders[$i].Name;
    $files=@(dir -literal $folders[$i].FullName|?{('.txt' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])});
    for($j=0;$j -lt $files.length;$j++){
        $filepath=$files[$j].FullName.Substring($current.length);
        $arr=New-Object -TypeName System.Collections.ArrayList;
        $text=[IO.File]::ReadAllText($files[$j].FullName, $enc);
        $text=[regex]::replace($text, $reg, {
            param($m);
            $it=$m.groups[0].value;
            if($it.length -gt 6){
                [void]$arr.add($it);
                return '';
            }else{return $it;}
        });
        if($arr.count -gt 0){
            [IO.File]::WriteAllText($files[$j].FullName, $text, $enc);
            $line=$filepath+"`r`n"+($arr -join "`r`n");
            $sw.WriteLine($line);
            $sw.WriteLine('');
            $sw.Flush();
        }
    }
}
$sw.Close();
$fs.Close();COPY
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

返回列表