I use GROUPBY=modifieddate.
Everything is neatly grouped until the files are older than 2 years. Then it's grouped into one big blob called 'A long time ago'.
Is it possible to divide this a bit further? For example, let's say 3, 5, 7, 10, 15, 20 years ago?
In the future we plan to make this more configurable but at the moment the only way to get custom grouping is to make a script column and then group by that. Script columns can define any groups they want.
Then I have to wait for that new feature because I have no idea how such a script column works. I did come across some sample scripts but I don't understand them. No problem. I'm sorting by the modified date column for now.
Here is a script that introduces a column Age and lets you define groups how you want them. Just whistle if you need help adapting them to your liking.
function OnInit(initData) {
initData.name = 'Age';
initData.version = '2021-12-09';
initData.copyright = '';
initData.url = 'https://resource.dopus.com/t/groupby-modifieddate-break-a-long-time-ago-in-smaller-junks/40038';
initData.desc = '';
initData.default_enable = true;
initData.min_version = '12.0';
}
function OnAddColumns(addColData) {
var col = addColData.AddColumn();
col.name = 'Age';
col.label = 'Age';
col.header = 'Age';
col.justify = 'right';
col.autogroup = false;
col.grouporder = 'one month;half a year;one year;3 years;5 years;7 years;10 years;15 years;20 years;over 20 years';
col.method = 'OnColumn';
}
function OnColumn(scriptColData) {
var age = (DOpus.Create().Date() - scriptColData.item.modify) / (1000 * 60 * 60 * 24); // age in days
var proseAge;
if (age < 30) {
proseAge = 'one month';
} else if (age < 180) {
proseAge = 'half a year';
} else if (age < 365) {
proseAge = 'one year';
} else if (age < 3 * 365) {
proseAge = '3 years';
} else if (age < 5 * 365) {
proseAge = '5 years';
} else if (age < 7 * 365) {
proseAge = '7 years';
} else if (age < 10 * 365) {
proseAge = '10 years';
} else if (age < 15 * 365) {
proseAge = '15 years';
} else if (age < 20 * 365) {
proseAge = '20 years';
} else {
proseAge = 'over 20 years'
}
scriptColData.value = proseAge;
scriptColData.sort = age;
scriptColData.group = proseAge;
}
A big thank you for this script. You made my day.
Hi, when I switch to 'Flat view Mixed (No Folders)', the script is not working anymore, whether all subfolders have an Age column or not. I now get a group called 'Unspecified' with all files from the sub folders in it.
Is there a way to get around this? Although not mentioned, Grouping by Age in Flat view was the reason for my original question. So I hope this is possible.
Edit: I noticed it does work in 'Flat view Mixed' (so with folders displayed).
Edit 2: I added a column Age to the Folder Format of 'Flat view' and made sure the folder format in the lister is not locked. This way everything is grouped as expected. I only don't understand why this all isn't needed for 'Flat View Mixed'. But hey, it works so I'm happy.
Hello lxp - apologies if I should not resurrect this thread, but I'm having a similar issue.
Is there any way to modify a script like this to actually use "every day" as a group? Meaning, if I have files from August 1, August 2, August 3, etc... That each day would be represented as an individual group?
Thanks,
Try this add-in. Sounds like it could do what you want.
Loading my directory now...this is perfect!
Exactly what I was looking for, lxp. Thank you so much!