[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
test.bat, ansi编码
  1. #&@cls&cd /d "%~dp0" & powershell -c "Get-Content '%~0' | Select-Object -Skip 1 | Out-String | Invoke-Expression" & pause&exit
  2. #文件
  3. $src_js = 'plugins.js'
  4. #要比较的数据
  5. $const1 = '{"name":"Cheat_Menu","status":true,"description":"","parameters":{}},'
  6. $const2 = '{"name":"Drill_SpeedGear","status":true,"description":"[v1.2]        系统 - 变速齿轮","parameters":{"初始齿轮速度":"2.50","是否绑定齿轮到变量":"false","绑定的变量":"0","声音是否变速":"true","声音变速同步率":"0.25"}}'
  7. #读取
  8. [string[]]$txt_list = Get-Content $src_js -Encoding UTF8 | Where-Object { $_ -notmatch '^\s+$'}
  9. #比较并输出
  10. &{
  11.     $txt_list[0..($txt_list.Length - 2)]
  12.     if($txt_list[$txt_list.Length - 3] -ne $const1 -and $txt_list[$txt_list.Length - 2] -ne $const2){
  13.         $const1
  14.         $const2
  15.     }
  16.     $txt_list[$txt_list.Length - 1]
  17. } | Out-File $src_js -Encoding utf8
复制代码
你的js文件其中有一行5万多个字符,纯bat读取不了
1

评分人数

TOP

回复 14# hfstar


    复制替换
  1. #&@cls&cd /d "%~dp0" & powershell -c "$cur_path='%~dp0';Get-Content '%~0' | Select-Object -Skip 1 | Out-String | Invoke-Expression" & pause&exit
  2. #文件
  3. $src_js = $cur_path + 'www\js\plugins.js'
  4. if(![System.IO.File]::Exists($src_js)){
  5. $src_js = $cur_path + 'js\plugins.js'
  6. if(![System.IO.File]::Exists($src_js)){
  7. Write-Host '没有发现 plugins.js'
  8. exit
  9. }
  10. }
  11. #要比较的数据
复制代码
1

评分人数

TOP

返回列表