- <# :
- 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
- #>
-
- $oldstr='www.baidu.com';
- $newstr='www.qq.com';
-
- #原文件编码为ANSI/GB2312, 则改为[Text.Encoding]::Default
- $enc=[Text.Encoding]::UTF8;
-
- $ext=@('.php', '.jsp', '.ini', '.html', '.xml', '.css', '.js', '.tpl', '.json', '.config');
-
- $files=@(dir -liter $args[0] -recurse|?{($ext -contains $_.Extension) -and ($_ -is [System.IO.FileInfo])});
- for($i=0;$i -lt $files.length;$i++){
- write-host $files[$i].FullName;
- $text=[IO.File]::ReadAllText($files[$i].FullName, $enc);
- $text=$text.replace($oldstr, $newstr);
- [IO.File]::WriteAllText($files[$i].FullName, $text, $enc);
- }
复制代码
|