This script button worked fine in older versions, but it no longer functions in 13.16.1 (Beta):
function OnClick(clickData) {
var cmd = clickData.func.command;
var tab = clickData.func.sourcetab;
var selectedFiles = tab.selected_files;
if (selectedFiles.count < 8) {
DOpus.Output("至少需要选择7个文件。");
return;
}
cmd.deselect = false;
cmd.Clear();
var renameCommands = ['F','R','LS','RS','T','B','P','P2'];
for (var i = 0; i < 8; i++) {
var file = selectedFiles(i);
var newName = renameCommands[i];
cmd.AddLine('Rename IGNOREEXT FROM="' + file + '" TO="' + newName + '"');
}
cmd.Run();
}
It no longer renames files as expected. No error appears, just no result.
Could this be a change in how selected_files() works or in the Rename command?
After your suggestion, I tested the script again carefully. It turns out that the issue happens only when exactly 7 files are selected — in that case, nothing happens. When I select 8 files, everything works as expected.
So now I'm not sure if it's really a bug or just a logic issue in my script. It's a bit confusing, but I appreciate your help pointing me in the right direction.
You were absolutely right — the issue was in my own code. The script was intentionally exiting when fewer than 8 files were selected. I've now corrected the logic, and everything is working perfectly after testing.
Honestly, I'm not sure why it seemed to work in earlier versions — that’s what led me to think it might be a regression. But clearly, the problem was with my code, not the update.
Apologies for the confusion and for taking up your time. I really appreciate the support.