// https://resource.dopus.com/t/suffix-number-of-subfolders/39876
var fso = new ActiveXObject('Scripting.FileSystemObject');
function OnGetNewName(getNewNameData) {
var item = getNewNameData.item;
if (!item.is_dir) return false;
var k = fso.GetFolder(item).SubFolders.count;
return k > 0 ? getNewNameData.newname + '+' + k : false;
}
// https://resource.dopus.com/t/suffix-number-of-subfolders/39876
var fsu = DOpus.FSUtil();
var fso = new ActiveXObject('Scripting.FileSystemObject');
function OnGetNewName(getNewNameData) {
var item = getNewNameData.item;
if (!item.is_dir) return false;
// var k = fso.GetFolder(item).SubFolders.count;
var k = CountNonEmptySubFolders(item);
return k > 0 ? getNewNameData.newname + '+' + k : false;
}
function CountNonEmptySubFolders(dir) {
var k = 0;
var folderEnum = fsu.ReadDir(dir, 'r');
while (!folderEnum.complete) {
var folderItem = folderEnum.Next();
if (!folderItem.is_dir) continue;
if (fso.GetFolder(folderItem).size == 0) continue;
k++;
}
return k;
}
Everything is ok no problem at all
all you have to do is add some buttons standard code for works your button;
here we go
// https://resource.dopus.com/t/suffix-number-of-subfolders/39876
@nodeselect
RENAME PATTERN="*" TO="*"
@script Jscript
var fsu = DOpus.FSUtil();
var fso = new ActiveXObject('Scripting.FileSystemObject');
function OnGetNewName(getNewNameData) {
var item = getNewNameData.item;
if (!item.is_dir) return false;
// var k = fso.GetFolder(item).SubFolders.count;
var k = CountNonEmptySubFolders(item);
return k > 0 ? getNewNameData.newname + '+' + k : false;
}
function CountNonEmptySubFolders(dir) {
var k = 0;
var folderEnum = fsu.ReadDir(dir, 'r');
while (!folderEnum.complete) {
var folderItem = folderEnum.Next();
if (!folderItem.is_dir) continue;
if (fso.GetFolder(folderItem).size == 0) continue;
k++;
}
return k;
}
Try This.
One more things Don't forget to set the buttons function as Standard function
If you already have a rename preset set up, you can simply call it from a button via a single-line command, without having to reproduce all the script code in the button (which also means you have to remember to edit both copies if you make changes later on).
Lxp linked to the post showing how to do this earlier in the thread.