- <#*,:&cls
- @echo off
- cd /d "%~dp0"
- powershell -NoProfile -ExecutionPolicy RemoteSigned -Command ". ([ScriptBlock]::Create((Get-Content -LiteralPath \"%~0\" -ReadCount 0 | Out-String ))) "
- exit /b
- #>
- # 源文件
- $srcfile = "src.txt"
- # 新文件
- $dstfile = "dst.txt"
- # 查找文本
- $search = "0x00"
-
- $encoding = [System.Text.Encoding]::Default
- $txt = [System.IO.File]::ReadAllText($srcfile, $encoding)
- $lines = $txt -split '(\r\n){2,}' | ForEach-Object {
- if ($_.Contains($search)) {
- ''
- $_
-
- }
- }
- [System.IO.File]::WriteAllLines($dstfile, $lines, $encoding)
复制代码
|