Page 1 of 1

Calculated column with bar as % of parent folder

Posted: 23 Aug 2023 17:54
by bossi
Hi folks ,
I am sure this can be done inside a calculated column.

This topic gives an idea how it could be done
viewtopic.php?t=18356

i'd like to replicate it like this example in from TreeSize shows:
F_-_TreeSize_2023-08-23_18-38-20.png
just need to know how to grab the parent folder size ...

Re: Calculated column with bar as % of parent folder

Posted: 23 Aug 2023 18:48
by highend

Code: Select all

    if (<cc_isfolder>) {
        $parent = gpc(<cc_item>, "component", -2, 1);
    }
    $foldersize = foldersize($parent, <r>);

Re: Calculated column with bar as % of parent folder

Posted: 23 Aug 2023 21:32
by bossi
Thanks sir for helping me out .
Fimggraphic_-_XYplorer_24.80_2023-08-23_22-27-56.png
it does the job , except in the root of a drive , propably needs an additional case for that

the code :

Code: Select all

if (<cc_isfolder>) 
	{$size = foldersize(<cc_item>, "<r>");
	$parent = gpc(<cc_item>, "component", -2, 1);} 
else 
	{$size = filesize(<cc_item>);
	$parent = gpc(<cc_item>, "path");}
$percentage =  ($size / foldersize($parent,<r>))*200+1;// (200+1) adjusts the size of the bar
return '>draw.bar ' . $percentage \ 1. ', AA4400';

Re: Calculated column with bar as % of parent folder

Posted: 23 Aug 2023 21:56
by highend
Probably because foldersize fails if it stumbles upon non-accessible folders during scanning (e.g. System Volume Information) so you would need to exclude such folders.

Apart of that I wouldn't use this method, the more items in the current list, the deeper the hierarchy of folders... It would become slower and slower.

The approach of choice would be: Use Everything and query it for the necessary data (folder size storing needs to be enabled ofc)

Re: Calculated column with bar as % of parent folder

Posted: 24 Aug 2023 17:04
by bossi
Its rather because $parent returns an empty value when in the root of a disk.
But yeah . its rather slow on some directories , for my Media Disk its acceptable )
The approach of choice would be: Use Everything
what do you mean by everything sir ?

Re: Calculated column with bar as % of parent folder

Posted: 24 Aug 2023 17:33
by highend