If the names of files and folders can be alphabetically grouped according to whether they start with the letters A-H, I-P and Q-Z, they should also be able to be sorted numerically according to the same principle. That is: 0-9, 10-19 … 90-99 and 100-199, 900-999 and so on and so forth. Maybe instead of names, they should be called “sequences” within a folder??? In any case, this does not seem to be possible, neither in Windows Explorer, File Explorer nor in Directory Opus. Am I wrong? If so, how would I do this manually or programmatically?
That could be done using a script add-in column. They can group files any way you want.
I really do not know how to do a script add-in column. Is there any way that I can learn it?
Here's a script column that assigns files to groups of numbers.
function OnInit(initData) {
initData.name = 'LogGroup';
initData.version = '2023-07-06';
initData.url = 'https://resource.dopus.com/t/grouping-of-file-and-folder-names/44942';
initData.desc = '';
initData.default_enable = true;
initData.min_version = '12.0';
}
function OnAddColumns(addColData) {
var col = addColData.AddColumn();
col.name = 'LogGroup';
col.justify = 'right';
col.method = 'OnColumn';
}
function OnColumn(scriptColData) {
var item = scriptColData.item;
if (item.is_dir) return;
var itemNo = item.name_stem.replace(/0*(\d+).*/, '$1');
if (itemNo == '') {
scriptColData.value = 'none';
return;
}
var groupSize = Math.pow(10, itemNo.length - 1);
if (groupSize < 10) groupSize = 10;
var start = Math.floor(Number(itemNo) / groupSize) * groupSize;
var end = start + groupSize - 1;
scriptColData.value = start + '..' + end;
}
To install, save ColumnLogGroup.js.txt to
%appdata%\GPSoftware\Directory Opus\Script AddIns
The column can be toggled with
Set COLUMNSTOGGLE="scp:LogGroup/LogGroup(!,a,0)"
The files can be grouped with
Set GROUPBY=scp:LogGroup/LogGroup
If all of this sounds a bit strange, read here
1 Like
This is good for numbered files only. Lettered files and folders at all are not grouped properly.
Yes. That was the idea. Feel free to enhance the script.
1 Like