- <#*,:&cls
- @echo off
- cd /d "%~dp0"
- powershell -NoProfile -ExecutionPolicy RemoteSigned -Command ". ([ScriptBlock]::Create((Get-Content -LiteralPath \"%~0\" -ReadCount 0 | Out-String ))) "
- pause
- exit /b
- #>
- $evaluator = [System.Text.RegularExpressions.MatchEvaluator] {
- param([System.Text.RegularExpressions.Match]$m)
- ([long]$m.Value - 600).ToString()
- }
- $re = [regex]'(?i)(?<=\$BB0)\d+(?=\$HH)'
- Get-ChildItem -Path .\*.txt | ForEach-Object {
- if (-not $_.psiscontainer) {
- $lines = [System.IO.File]::ReadAllLines($_.FullName)
- for ($i = 0; $i -lt $lines.Count; $i++) {
- if ($lines[$i] -match '\$CC32') {
- $lines[$i] = $re.Replace($lines[$i], $evaluator)
- }
- }
- [System.IO.File]::WriteAllLines($_.FullName,$lines)
- }
- }
复制代码
|