[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. <# :
  2. cls&echo off&cd /d "%~dp0"&mode con lines=5000
  3. path %SYSTEMROOT%\System32\WindowsPowerShell\v1.0;%path%
  4. set "current=%cd%"
  5. powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression"
  6. pause
  7. exit
  8. #>
  9. $current=($env:current).trimend('\');
  10. $logfile=$current+'\info.txt';
  11. $enc=New-Object System.Text.UTF8Encoding $False;
  12. $fs=New-Object System.IO.FileStream($logfile, [System.IO.FileMode]::Create);
  13. $sw=New-Object System.IO.StreamWriter($fs, $enc);
  14. $reg='[\x21-\x27\x2a-\x3b\x3f-\x7e\x3d]+(\.com|\.cn|\.cc|\.net|\.org|\.top|\.vip)[\x21-\x27\x2a-\x3b\x3f-\x7e\x3d]*';
  15. $folders=@(dir -literal $current|?{$_ -is [System.IO.DirectoryInfo]});
  16. for($i=0;$i -lt $folders.length;$i++){
  17.     write-host $folders[$i].Name;
  18.     $files=@(dir -literal $folders[$i].FullName|?{('.txt' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])});
  19.     for($j=0;$j -lt $files.length;$j++){
  20.         $filepath=$files[$j].FullName.Substring($current.length);
  21.         $arr=New-Object -TypeName System.Collections.ArrayList;
  22.         $text=[IO.File]::ReadAllText($files[$j].FullName, $enc);
  23.         $text=[regex]::replace($text, $reg, {
  24.             param($m);
  25.             $it=$m.groups[0].value;
  26.             if($it.length -gt 6){
  27.                 [void]$arr.add($it);
  28.                 return '';
  29.             }else{return $it;}
  30.         });
  31.         if($arr.count -gt 0){
  32.             [IO.File]::WriteAllText($files[$j].FullName, $text, $enc);
  33.             $line=$filepath+"`r`n"+($arr -join "`r`n");
  34.             $sw.WriteLine($line);
  35.             $sw.WriteLine('');
  36.             $sw.Flush();
  37.         }
  38.     }
  39. }
  40. $sw.Close();
  41. $fs.Close();
复制代码
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

返回列表