修改原文件,注意备份- <# :
- cls
- @echo off
- set info=互助互利,支付宝扫码头像,感谢打赏
- rem 有问题,可加QQ956535081及时沟通
- title %info%
- set "rootpath=%~dp0"
- if "%rootpath:~-1%" equ "\" (set "rootpath=%rootpath:~,-1%")
- cd /d "%rootpath%"
- powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default))) -Args '%rootpath%'"
- echo;%info%
- pause
- exit
- #>
-
- $n=19;
- $files=@(dir -liter $args[0]|?{(@('.txt') -contains $_.Extension) -and ($_ -is [System.IO.FileInfo])});
- for($i=0;$i -lt $files.length;$i++){
- write-host $files[$i].Name;
- $text=[IO.File]::ReadAllText($files[$i].FullName, [Text.Encoding]::Default);
- $text=$text -replace '(?<=\x0C)\s+$','';
- $text=$text -split '\n';
- if($text.length -ge $n){$text[$n-1]=$text[$n-1] -replace '\x0C','';};
- $text=$text -join "`n";
- [IO.File]::WriteAllText($files[$i].FullName, $text, [Text.Encoding]::Default);
- }
复制代码
|