test.bat, ansi编码- #&@cls&cd /d "%~dp0" & powershell -c "Get-Content '%~0' | Select-Object -Skip 1 | Out-String | Invoke-Expression" & pause&exit
- #文件
- $src_js = 'plugins.js'
- #要比较的数据
- $const1 = '{"name":"Cheat_Menu","status":true,"description":"","parameters":{}},'
- $const2 = '{"name":"Drill_SpeedGear","status":true,"description":"[v1.2] 系统 - 变速齿轮","parameters":{"初始齿轮速度":"2.50","是否绑定齿轮到变量":"false","绑定的变量":"0","声音是否变速":"true","声音变速同步率":"0.25"}}'
- #读取
- [string[]]$txt_list = Get-Content $src_js -Encoding UTF8 | Where-Object { $_ -notmatch '^\s+$'}
- #比较并输出
- &{
- $txt_list[0..($txt_list.Length - 2)]
- if($txt_list[$txt_list.Length - 3] -ne $const1 -and $txt_list[$txt_list.Length - 2] -ne $const2){
- $const1
- $const2
- }
- $txt_list[$txt_list.Length - 1]
- } | Out-File $src_js -Encoding utf8
复制代码 你的js文件其中有一行5万多个字符,纯bat读取不了 |