- <# :
- 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
- #>
-
- $txtfile='.\xx.txt';
-
- $list='
- 深圳市南山区|南山区,
- 深圳市宝安区|宝安区,
- 深圳市福田区|福田区,
- 深圳市龙岗区|龙岗区,
- ';
-
- $txtfile=$txtfile -replace '^\.',$args[0];
- $arr=$list.trim() -split '[\r\n]+';
- $enc=[Text.Encoding]::Default;
- $text=[IO.File]::ReadAllText($txtfile,$enc);
- for($j=0;$j -lt $arr.length;$j++){
- $brr=$arr[$j].split('|',2);
- $text=$text.replace($brr[0],$brr[1]);
- };
- [IO.File]::WriteAllText($txtfile, $text, $enc);
复制代码
|