You select a directory and run the script.
It counts the files in the selected directory and appends that count at the end of folder name.
My use case: I needed this because there are multiple song mixing versions and we wanted the track count easily seen in the folder name for a quicker identification of the mix complexity.
With over 500 songs w/ all versions doing this manually wasn't going to happen soon.
John Smith - Happy Birthday (34 tracks)
The same concept could be used to put anything in the folder name once its selected.
Thought I would share:
function OnClick(clickData) {
var tab = clickData.func.sourcetab;
var sel = tab.selected;
for (var e = new Enumerator(sel); !e.atEnd(); e.moveNext()) {
var item = e.item();
if (!item.is_dir) continue;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var folder = fso.GetFolder(item.realpath);
var count = 0;
var files = new Enumerator(folder.Files);
for (; !files.atEnd(); files.moveNext()) count++;
var originalPath = item.realpath;
var parentPath = fso.GetParentFolderName(originalPath);
var baseName = item.name.replace(/\s\(\d+\stracks\)$/i, ""); // Remove any previous suffix
var newName = baseName + " (" + count + " tracks)";
var newPath = fso.BuildPath(parentPath, newName);
// Rename using internal command
clickData.func.command.ClearFiles();
clickData.func.command.AddFile(item);
clickData.func.command.RunCommand('Rename FROM="' + originalPath + '" TO="' + newPath + '"');
}
}

