fix(rename): guard Add prefix against double-prefixing

Skip objects whose displayName or description already starts with
the requested prefix. This makes Add prefix idempotent.
This commit is contained in:
2026-04-14 19:02:06 +02:00
parent cd1c004f4b
commit 6703625c00

View File

@@ -332,7 +332,7 @@ foreach($obj in $selectedObjects)
switch($mode) switch($mode)
{ {
"Search and replace" { if($oldName -match $searchPattern) { $newName = $oldName -replace $searchPattern, $replacePattern } } "Search and replace" { if($oldName -match $searchPattern) { $newName = $oldName -replace $searchPattern, $replacePattern } }
"Add prefix" { $newName = "$prefix$oldName" } "Add prefix" { if(-not $oldName.StartsWith($prefix)) { $newName = "$prefix$oldName" } }
"Strip prefix" { if($oldName.StartsWith($prefix)) { $newName = $oldName.Substring($prefix.Length) } } "Strip prefix" { if($oldName.StartsWith($prefix)) { $newName = $oldName.Substring($prefix.Length) } }
} }
} }
@@ -341,7 +341,7 @@ foreach($obj in $selectedObjects)
switch($mode) switch($mode)
{ {
"Search and replace" { if($oldDesc -match $searchPattern) { $newDesc = $oldDesc -replace $searchPattern, $replacePattern } } "Search and replace" { if($oldDesc -match $searchPattern) { $newDesc = $oldDesc -replace $searchPattern, $replacePattern } }
"Add prefix" { $newDesc = "$prefix$oldDesc" } "Add prefix" { if(-not $oldDesc.StartsWith($prefix)) { $newDesc = "$prefix$oldDesc" } }
"Strip prefix" { if($oldDesc.StartsWith($prefix)) { $newDesc = $oldDesc.Substring($prefix.Length) } } "Strip prefix" { if($oldDesc.StartsWith($prefix)) { $newDesc = $oldDesc.Substring($prefix.Length) } }
} }
} }