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:
@@ -332,7 +332,7 @@ foreach($obj in $selectedObjects)
|
||||
switch($mode)
|
||||
{
|
||||
"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) } }
|
||||
}
|
||||
}
|
||||
@@ -341,7 +341,7 @@ foreach($obj in $selectedObjects)
|
||||
switch($mode)
|
||||
{
|
||||
"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) } }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user