本帖最后由 zaqmlp 于 2022-7-16 10:12 编辑
- <# :
- cls&echo off&cd /d "%~dp0"&mode con lines=5000&rem bat存为ANSI/GB2312编码
- set "current=%cd%"
- powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression"
- pause
- exit
- #>
- $current=$env:current;
-
- $exclude=@(
- "222"
- "nnn"
- );
-
- $findtag=@(
- '<!--开屏变量播放-->'
- '<!--xxxx-->'
- );
-
-
- $enc=New-Object System.Text.UTF8Encoding $False;
- $folders=@(dir -literal $current|?{($exclude -notcontains $_.Name) -and ($_ -is [System.IO.DirectoryInfo])});
- for($i=0;$i -lt $folders.length;$i++){
- $files=@(dir -literal $folders[$i].FullName -recurse|?{('.xml' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])});
- for($j=0;$j -lt $files.length;$j++){
- write-host $files[$j].FullName;
- $text=[IO.File]::ReadAllText($files[$j].FullName, $enc);
- for($k=0;$k -lt $findtag.length;$k++){
- #$reg=[regex]::Escape($findtag[$k])+'\s+?[^\r\n]+';
- $reg=[regex]::Escape($findtag[$k])+'[\s\S]*?(?=<!--)';
- $text=$text -replace $reg,'';
- }
- [IO.File]::WriteAllText($files[$j].FullName, $text, $enc);
- }
- }
复制代码
|