As the title says. Rename scripts with javascript stopped working in beta 13.
Problem seems to persist in beta 14.
Vbscripts work without a problem.
Seems it's actually not the rename script's fault but the selection gets passed wrong.
Loading a rename script in the advanced dialog populates the Old Name new Name Fields with bogus values which was not the case pre-b13.
Rename PRESET=Clean stopped doing anything.
Old name new name should be disabled in script mode and never saved as part of the preset in that mode.
function OnGetNewName(getNewNameData) {
var item = getNewNameData.item;
var meta = item.metadata;
var name = item.name_stem;
//unUrlEncode
name = decodeURIComponent(name);
if (item.is_dir) {
//isdir
//handle dates <2000 eg.[991121]
name = name.replace(/\[((?:8|9)\d)-?(\d{2})-?(\d{2})\]/g, " [19$1-$2-$3] ");
//>2000 eg [160812]
name = name.replace(/\[([0-5]\d)-?(\d{2})-?(\d{2})\]/g, " [20$1-$2-$3] ");
}
else {
//isfile
switch (item.ext) {
case ".rar":
case ".zip":
case ".7z":
//bracket spacing
name = name.replace('(', '(');
name = name.replace(')', ') ');
name = name.replace('?', '-');
name = name.replace('( ', '(');
name = name.replace(' )', ') ');
name = name.replace('[ ', '[');
name = name.replace(' ]', '] ');
name = name.replace('] - ', '] ');
name = name.replace(')(', ') ( ');
name = name.replace(')[', ') [');
name = name.replace('][', '] [');
name = name.replace(')[', ') [');
name = name.replace(')]', ')] ');
name = name.replace('-00]', '] ');
name = name.replace(') ]', ')] ');
name = name.replace('- -', '-');
name = name.replace('号', '');
name = name.replace('[[', '[');
name = name.replace(']]', '] ');
//Misc replacements
name = name.replace(/(.*?)(?:Vol\.|Vol\.|Vol)(\d*)(.*)/g, "$1 Vol.$2 $3");
//reorder stuff
//[#] at end
name = name.replace(/(.*?)\[#\](.*)/g, "$1 $2 [#]");
//rating
name = name.replace(/(.*?)\[(★\d)\](.*)/g, "$1 $3 $2");
//underscores
name = name.replace('_', ' ');
//special cases keep underscore
name = name.replace(' TRi', '_TRi');
//trim double space
name = name.replace(/\s\s+/g, ' ');
//trim whitespace
name = name.replace(/^\s*(.*?)\s*$/g, "$1");
//all cases
break;
}
}
//final filename
return name + item.ext;
}
Resaving the script with
Old Name: *
New Name: *
fixed it.
Values were probably ignored pre-b13.
Correct, there was a change so that the old and new name wildcards are now always correctly applied, instead of being ignored if either didn't contain a wildcard character (which made certain operations impossible, and caused some confusion over the years).
Rename presets saved that way will need to be updated with proper wildcards (usually just * in both fields, as you've done).
Good to know. Thanks for getting to the bottom of it leo.
In beta 15 we've improved the compatibility with old presets, so this problem should hopefully not arise again.