[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
test.bat
ansi编码,和amp_.h放到一起运行
  1. #&cls&@cd /d "%~dp0"&powershell -c "Get-Content '%~0' | Out-String | Invoke-Expression" & pause&exit
  2. cls
  3. #映射关系表
  4. $map = @(
  5.     'amp_.h',
  6.     'move-l_format.c -> m_reg_tab -> m_reg_tab_l',
  7.     'move-r_format.c -> m_reg_tab -> m_reg_tab_r',
  8.     'move-c_format.c -> m_reg_tab -> m_reg_tab_cen',
  9.     'move-l_format.c -> m_ram1_tab -> eq_tables_ram1_left_movie',
  10.     'move-r_format.c -> m_ram1_tab -> eq_tables_ram1_right_movie',
  11.     'move-c_format.c -> m_ram1_tab -> eq_tables_ram1_cen_movie',
  12.     'music-l_format.c -> m_ram1_tab -> eq_tables_ram1_left_music',
  13.     'music-r_format.c -> m_ram1_tab -> eq_tables_ram1_right_music',
  14.     'music-c_format.c -> m_ram1_tab -> eq_tables_ram1_cen_music',
  15.     'news-l_format.c -> m_ram1_tab -> eq_tables_ram1_left_news',
  16.     'news-r_format.c -> m_ram1_tab -> eq_tables_ram1_right_news',
  17.     'news-c_format.c -> m_ram1_tab -> eq_tables_ram1_cen_news'
  18. )
  19. #读取源
  20. $src_str = Get-Content $map[0] | Out-String
  21. #循环读取新数据
  22. $map | Select-Object -Skip 1 | foreach {
  23.     $arr = $_ -split '->' | foreach { $_.Trim() }
  24.     Write-Host ('文件 {0} 中 {1} 数组数据更新到文件 {2} 中 {3} 数组' -f $arr[0],$arr[1],$map[0],$arr[2])
  25.     $str = Get-ChildItem $arr[0] -Recurse | Select-Object -First 1 | Get-Content | Out-String
  26.     if($str -match ('(?s){0}\[\]\s*=\s*{{\s*\n(.*?)}};' -f $arr[1])){
  27.         $s1 = $Matches[1]
  28.         $src_str = $src_str -replace ('(?s)(?<={0}\[\]\s*=\s*{{\s*\n)(.*?)(?=}};)' -f $arr[2]),$s1
  29.     }
  30. }
  31. #输出新数据
  32. $src_str | Out-File $map[0] -Encoding Default
  33. Write-Host '更新已完成'
复制代码

TOP

返回列表