本帖最后由 smss 于 2019-6-4 15:25 编辑
回复WHY
图1图2是a文件和b文件比对存在的问题 如果名称是A 替换成了B 当出现@AA或者@ABC时(且没有任何name="AA"与之关联时)会被替换成@BA或@BBC
 
图3是c文件和d文件比对存在的问题

如何批量删除src=""中.png.jpg.webp 及srcExp=""中.png.jpg.webp或+'.png'+'.jpg'+'.webp'同步变更目录下脚本中涉及的图片名称
如
<Image src="Ai/123.png" x="0" y="0"/>
<Image src="Ai/c.jpg" x="100" y="20"/>
<Image src="Ai/345.webp" x="1003" y="203"/>
<Image srcExp="'Ai/timing/'+ifelse(#start_pause==1,'Stop','count')+'.png'"/> 注意其中可能涉及变量名需要同步
方案A 改名称为A~ZZZZ之间
<Image src="Ai/A" x="0" y="0"/>
<Image src="Ai/B" x="100" y="20"/>
<Image src="Ai/C" x="1003" y="203"/>
<Image srcExp="'Ai/timing/'+ifelse(#start_pause==1,#A,#B)+'.png'"/>
方案B 仅删除后缀 但是需要规避重名 (如同时出现1.png和1.jpg时 删除后缀将导致重名冲突)
<Image src="Ai/123" x="0" y="0"/>
<Image src="Ai/c" x="100" y="20"/>
<Image src="Ai/345" x="1003" y="203"/>
<Image srcExp="'Ai/timing/'+ifelse(#start_pause==1,'Stop','count')"/>
还有我应该怎样改成 PowerShell "" 这样以BAT方式运行的 加了几个^有什么特殊的地方说明吗?
以下是目前的 | $global:n = 0; $Hash=@{}; | | $str = [IO.File]::ReadAllText('manifest.xml',[Text.Encoding]::Default); | | | | | | $reg1 = '(?<=<(?!Extra)[^<>]*\sname=")(?!notice)(?!music_(?:prev|display|next|play|pause|album_cover))(?!notification_(?:icon|title|content|time|info|subtext|key|list))[^"]+(?=")'; | | | | | | $reg2 = '(?<=\starget=")[^"]+(?="[^<>]*\scommand="play)|(?<=\scommand="play[^<>]*\starget=") [^"]+(?=")'; | | | | $str = [regex]::Replace($str, $reg1 + '|' + $reg2, { | | param($m); | | $key = $m.Value; | | if( !$Hash.ContainsKey($key) ){ | | $x = [Math]::floor( $global:n / 26 ); | | if($x) { $chr1 = [char]( 64 + [int]$x ) } else { $chr1 = '' } | | $Hash[$key] = $chr1 + [char]( 65 + $global:n++ % 26 ); | | } | | $Hash[$key]; | | }) | | | | $arrKey = $Hash.Keys | sort -Desc {$_.Length}; | | | | | | $str = [regex]::Replace($str, '(?<=")([^"@#]*[@#][^"]+|[^"]+(?:\.animation|\.visibility))(?=")', { | | param($m); | | $s = $m.Groups[1].Value; | | forEach( $key In $arrKey ) { | | $s = $s.Replace( '@' + $Key, '@' + $Hash[$Key] ); | | $s = $s.Replace( '#' + $Key, '#' + $Hash[$Key] ); | | $s = $s.Replace( $Key + '.animation', $Hash[$Key] + '.animation' ); | | $s = $s.Replace( $Key + '.visibility', $Hash[$Key] + '.visibility' ); | | } | | $s; | | }) | | | | [IO.File]::WriteAllText('manifest2.xml', $str, [Text.Encoding]::UTF8); | | | | $str = [IO.File]::ReadAllText('config.xml', [Text.Encoding]::Default); | | $str = [regex]::Replace($str, '(?<=\sid=")[^"]+(?=")', {param($m); if($Hash[$m.Value]){$Hash[$m.Value]}else{$m.Value}}); | | [IO.File]::WriteAllText('config2.xml', $str, [Text.Encoding]::UTF8); | | | | echo 'Done'; | | [Console]::ReadKey()COPY |
|