Hi,
Thanks for the details!
For Labeled parameters, the label names live in the enumerationLabels array, and need to be updated by copying the array and reassigning it back to the parameter.
I have modified the original batch rename script to make it work for the selected labeled parameter’s labels.
You can run it via Scripts > FMOD Examples > Batch Rename Labels
studio.menu.addMenuItem({
name: "FMOD Examples\\Batch Rename Labels",
isEnabled: function () {
var cur = studio.window.browserCurrent();
return cur && cur.parameter && cur.parameter.enumerationLabels;// Make sure the selected item is label parameter
},
execute: function () {
var cur = studio.window.browserCurrent();
var p = cur.parameter;
if (!p || !p.enumerationLabels) {
studio.system.message("Please select a Labeled Parameter.");
return;
}
var findStr = "";
var replaceStr = "";
var dialogRoot = null;
//Update the preview
function updatePreview() {
if (!dialogRoot) return;
var labels = p.enumerationLabels || [];
var lines = [];
for (var i = 0; i < labels.length; i++) {
if (typeof labels[i] === "string" && labels[i].indexOf(findStr) === 0) {
var newName = replaceStr + labels[i].substring(findStr.length);
lines.push(labels[i] + " → " + newName);
}
}
var preview = dialogRoot.findWidget("m_preview");
if (!preview) return;
preview.setHtml(lines.length ? lines.join("<br/>") : '<font color="Gray">(no matching labels)</font>');
}
studio.ui.showModalDialog({
windowTitle: "Batch Rename Enum Labels",
windowWidth: 340,
windowHeight: 230,
widgetType: studio.ui.widgetType.Layout,
layout: studio.ui.layoutType.VBoxLayout,
contentsMargins: { left: 8, top: 8, right: 8, bottom: 8 },
spacing: 6,
// Get the dialogRoot
onConstructed: function () { dialogRoot = this; updatePreview(); },
items: [
{ widgetType: studio.ui.widgetType.Label, text: "Find" },
{
widgetType: studio.ui.widgetType.LineEdit,
widgetId: "m_find",
text: findStr,
onTextEdited: function () { findStr = this.text(); updatePreview(); }
},
{ widgetType: studio.ui.widgetType.Label, text: "Replace with" },
{
widgetType: studio.ui.widgetType.LineEdit,
widgetId: "m_replace",
text: replaceStr,
onTextEdited: function () { replaceStr = this.text(); updatePreview(); }
},
{ widgetType: studio.ui.widgetType.Label, text: "Preview" },
{
widgetType: studio.ui.widgetType.TextEdit,
widgetId: "m_preview",
isReadOnly: true,
minimumHeight: 90,
html: '<font color="Gray">(type Find/Replace to preview changes)</font>'
},
{
widgetType: studio.ui.widgetType.PushButton,
text: "Apply",
onClicked: function () {
//Copy, modify and reassign all target labels
var labels = p.enumerationLabels.slice();
var changed = 0;
for (var i = 0; i < labels.length; i++) {
if (typeof labels[i] === "string" && labels[i].indexOf(findStr) === 0) {
labels[i] = replaceStr + labels[i].substring(findStr.length);
changed++;
}
}
if (changed === 0) {
studio.system.message("No labels matched: " + findStr);
this.closeDialog();
return;
}
p.enumerationLabels = labels;
this.closeDialog();
}
}
]
});
}
});
Hope this helps! Let me know if it works.