test.bat
ansi编码,和amp_.h放到一起运行- #&cls&@cd /d "%~dp0"&powershell -c "Get-Content '%~0' | Out-String | Invoke-Expression" & pause&exit
- cls
- #映射关系表
- $map = @(
- 'amp_.h',
-
- 'move-l_format.c -> m_reg_tab -> m_reg_tab_l',
- 'move-r_format.c -> m_reg_tab -> m_reg_tab_r',
- 'move-c_format.c -> m_reg_tab -> m_reg_tab_cen',
-
- 'move-l_format.c -> m_ram1_tab -> eq_tables_ram1_left_movie',
- 'move-r_format.c -> m_ram1_tab -> eq_tables_ram1_right_movie',
- 'move-c_format.c -> m_ram1_tab -> eq_tables_ram1_cen_movie',
-
- 'music-l_format.c -> m_ram1_tab -> eq_tables_ram1_left_music',
- 'music-r_format.c -> m_ram1_tab -> eq_tables_ram1_right_music',
- 'music-c_format.c -> m_ram1_tab -> eq_tables_ram1_cen_music',
-
- 'news-l_format.c -> m_ram1_tab -> eq_tables_ram1_left_news',
- 'news-r_format.c -> m_ram1_tab -> eq_tables_ram1_right_news',
- 'news-c_format.c -> m_ram1_tab -> eq_tables_ram1_cen_news'
- )
- #读取源
- $src_str = Get-Content $map[0] | Out-String
- #循环读取新数据
- $map | Select-Object -Skip 1 | foreach {
- $arr = $_ -split '->' | foreach { $_.Trim() }
- Write-Host ('文件 {0} 中 {1} 数组数据更新到文件 {2} 中 {3} 数组' -f $arr[0],$arr[1],$map[0],$arr[2])
- $str = Get-ChildItem $arr[0] -Recurse | Select-Object -First 1 | Get-Content | Out-String
- if($str -match ('(?s){0}\[\]\s*=\s*{{\s*\n(.*?)}};' -f $arr[1])){
- $s1 = $Matches[1]
- $src_str = $src_str -replace ('(?s)(?<={0}\[\]\s*=\s*{{\s*\n)(.*?)(?=}};)' -f $arr[2]),$s1
- }
- }
- #输出新数据
- $src_str | Out-File $map[0] -Encoding Default
- Write-Host '更新已完成'
复制代码
|