Calculated column with bar as % of parent folder

Features wanted...
Post Reply
bossi
Posts: 144
Joined: 30 Jul 2022 11:09
Location: Win11-latest, XYx64 latest, 4K@100%

Calculated column with bar as % of parent folder

Post 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 ...
You do not have the required permissions to view the files attached to this post.

highend
Posts: 14925
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Calculated column with bar as % of parent folder

Post by highend »

Code: Select all

    if (<cc_isfolder>) {
        $parent = gpc(<cc_item>, "component", -2, 1);
    }
    $foldersize = foldersize($parent, <r>);
One of my scripts helped you out? Please donate via Paypal

bossi
Posts: 144
Joined: 30 Jul 2022 11:09
Location: Win11-latest, XYx64 latest, 4K@100%

Re: Calculated column with bar as % of parent folder

Post 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';
You do not have the required permissions to view the files attached to this post.

highend
Posts: 14925
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Calculated column with bar as % of parent folder

Post 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)
One of my scripts helped you out? Please donate via Paypal

bossi
Posts: 144
Joined: 30 Jul 2022 11:09
Location: Win11-latest, XYx64 latest, 4K@100%

Re: Calculated column with bar as % of parent folder

Post 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 ?

highend
Posts: 14925
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Calculated column with bar as % of parent folder

Post by highend »

One of my scripts helped you out? Please donate via Paypal

Post Reply