Make sure folder sizes are pre-calculated and visible in the source file display.
Create a button with this script:
function OnClick(clickData)
{
DOpus.ClearOutput();
var tab = clickData.func.sourcetab;
var dirs = tab.dirs;
var filter = DOpus.Create().Filter('=output(fullpath + " => size via Filter =" + size)');
for (var i = 0; i < dirs.count; i++){
DOpus.Output(dirs(i) + ' => size via Item =' + dirs(i).size);
var dummy = dirs(i).matchFilter(filter);
}
}
You can see in the Script Log (not the Command Editor log) that when you reference size in the filter clause, it doesn’t return the expected value (or anything) —even though Item.size shows it correctly.
Is this a bug?
Is there any way to force that data to be retrieved when used in filters?
Thanks.
Item.size is only providing a value there if the file display already has it (i.e. because folder sizes have already been calculated).
We can look at adding an evaluator function to calculate a folder size, but we don't want to make it happen automatically because potentially it can take a very long time. The only exception to this is a filter Size clause inside a Type > Folders Only subclause.
True.
Maybe if possible, populate the same value when used in a filter, but only if it has already been calculated ? One might assume that since item.size is returning a value, the same would apply when referring to size in a filter applied to the same Item object — but that's not the case.
Then the filter would work sometimes and not others, and you might think it was working when you first tested it, then find it doesn't work when you need to use it and haven't already calculated the sizes.
It should work now if the size test is inside a Folders-Only subclause (which makes it explicit that you need the size calculated for folders, not just files) like Jon described.