BUG: Show All Items In Branch (file size sum)

Things you’d like to miss in the future...
Forum rules
:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:

:info: Please include the following information:
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".

:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:
Sander Bouwhuis
Posts: 246
Joined: 10 Jun 2008 15:40
Location: Netherlands

BUG: Show All Items In Branch (file size sum)

Post by Sander Bouwhuis »

The 'Show All Items In Branch' feature (<CTRL>-F3) sums the sizes of all the files and directories. But, it counts a lot of files double:

Consider the following file:
Dir1\Dir2\Dir3\MyFile.txt (1 byte)

Now, if you press <CTRL>-F3 while in Dir 1, you will get the following view:

Code: Select all

2                       1 byte
3                       1 byte
MyFile.txt              1 byte
So, the total sum becomes 3 bytes, while the tree clearly contains only 1 byte.
This makes it very confusing when viewing a large amount of files.

zer0
Posts: 2676
Joined: 19 Jan 2009 20:11

Re: BUG: Show All Items In Branch (file size sum)

Post by zer0 »

I think all is in order, because you said it yourself that this feature sums the sizes of all files and directories. I don't see where that file is counted double, because the folder itself, as a container for other folders and files, uses a tiny amount of space and that amount is added to the total.
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

admin
Site Admin
Posts: 65334
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: BUG: Show All Items In Branch (file size sum)

Post by admin »

zer0 wrote:I think all is in order, because you said it yourself that this feature sums the sizes of all files and directories. I don't see where that file is counted double, because the folder itself, as a container for other folders and files, uses a tiny amount of space and that amount is added to the total.
I think iycgtptyarvg (cute name!) is right that it is at least misleading. The total size is simply the sum of all items in the Size column; if folder sizes are calculated then individual file sizes may be counted 2 times, 3 times, or more, depending on the depth of their position.

The solution would be not to add folder sizes to the sum.

zer0
Posts: 2676
Joined: 19 Jan 2009 20:11

Re: BUG: Show All Items In Branch (file size sum)

Post by zer0 »

admin wrote:I think iycgtptyarvg (cute name!) is right that it is at least misleading. The total size is simply the sum of all items in the Size column; if folder sizes are calculated then individual file sizes may be counted 2 times, 3 times, or more, depending on the depth of their position.

The solution would be not to add folder sizes to the sum.
I see. I did a little experimenting and turns out that this problem only occurs if, as you said, folder sizes are displayed in the Size column, which IIRC isn't on by default. I suppose a quick hack would be to divide the total sum by 2 to cure the duplicate sum calculation.
Reporting a bug? Have a wish? Got a question? Use search - View roadmap - FAQs: Forum + XY site
Windows 7/10
Always using the latest stable two-decimal build

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: BUG: Show All Items In Branch (file size sum)

Post by jacky »

admin wrote:I think iycgtptyarvg (cute name!) is right that it is at least misleading. The total size is simply the sum of all items in the Size column; if folder sizes are calculated then individual file sizes may be counted 2 times, 3 times, or more, depending on the depth of their position.

The solution would be not to add folder sizes to the sum.
hmm... I don't know about misleading, it's what to expect. You're not in a folder when that happens, you're showing search results, which might also come from different locations, etc So of course the total size announced might not represent anything "real."

You say you want to not add folder sizes to the sum, but what if my search was to return only folders, and I want to know how many space they all consume? Wouldn't each folder have a size and yet a "total: 0 byte" be confusing as well ??
Also, if folder sizes aren't counted on total, yet they are on selected, isn't that all the more confusing?? And if you plan on excluding them from selection, you'll hear me scream! :P ;)

I think it's a lot less confusing to say total is the total of all sizes listed, so most of the times it means something, and when that includes folders as well as folders within those folders, you got a total size that might not mean much; than to say total is files only, so it really never represents anything...

I don't think the way it is now is particularly confusing, you just have to realize you're listing SR, which might lead to the same folders showing up more than once. If you want the size of files only, just exclude (sub)folders from your search, or simply select all files! ;) (And it's even easier if you don't calculate folder sizes automatically ;))
Proud XYplorer Fanatic

admin
Site Admin
Posts: 65334
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: BUG: Show All Items In Branch (file size sum)

Post by admin »

jacky wrote:
admin wrote:I think iycgtptyarvg (cute name!) is right that it is at least misleading. The total size is simply the sum of all items in the Size column; if folder sizes are calculated then individual file sizes may be counted 2 times, 3 times, or more, depending on the depth of their position.

The solution would be not to add folder sizes to the sum.
hmm... I don't know about misleading, it's what to expect. ...
The nice thing about your reply is that it's not only right (as always) but also saves me work (as not always). :)

Sander Bouwhuis
Posts: 246
Joined: 10 Jun 2008 15:40
Location: Netherlands

Re: BUG: Show All Items In Branch (file size sum)

Post by Sander Bouwhuis »

Ok. How do I set the result for the 'Show all items' features to only show files? When I select 'Define current column layout as default', it will use it for ALL views. I only want to omit the folders in 'Show all items' mode.

Thanks for the quick replies, btw.
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.

admin
Site Admin
Posts: 65334
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: BUG: Show All Items In Branch (file size sum)

Post by admin »

iycgtptyarvg wrote:Ok. How do I set the result for the 'Show all items' features to only show files? When I select 'Define current column layout as default', it will use it for ALL views. I only want to omit the folders in 'Show all items' mode.

Thanks for the quick replies, btw.
That's not possible currently but I like the idea. I could either add a command "Show all files in branch" or add a modifier option to the "Show all items in branch". Hmmm...

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: BUG: Show All Items In Branch (file size sum)

Post by jacky »

admin wrote:That's not possible currently but I like the idea. I could either add a command "Show all files in branch" or add a modifier option to the "Show all items in branch". Hmmm...
Well, to keep with trying to make you not to do things ;) I would say it already is possible actually. There are indeed a couple of things one can already do presently:
- if you just want to know the total size of files only, right-click (or menu Edit) and Select All Files
- if you want the search results to only feature files (and no folders), click on TB button (or in menu View/Show Items) Show Folders In List (Hint: press the button before starting the search, it'll go faster since you skip a "refreshing" step)
Proud XYplorer Fanatic

Muroph
Posts: 561
Joined: 21 Aug 2007 16:13

Re: BUG: Show All Items In Branch (file size sum)

Post by Muroph »

use a search template. :wink:

i'm too lazy too explain, so i'll post a screenshot. :P
2009-08-08_10-34-05.jpg
2009-08-08_10-34-05.jpg (24.98 KiB) Viewed 3409 times
OBS: selected locations is optional, but gives you the ability to show all files inside selected folders only.
if nothing is selected, it will show all files in current branch.
2009-08-08_10-34-17.jpg
2009-08-08_10-34-17.jpg (21.13 KiB) Viewed 3409 times
then click "Templates" -> "Save to template" and give it a name.

to run this quickly you can use a script like

Code: Select all

loadsearch "<template_name>",r;
My shared scripts:
TeraCopy Integration, Tag Manager, Comments Menu, Text Replacer, Image and Media Tools, Checksum Calculator, Video Calculator
only 5 URLs are allowed on the sig...

Sander Bouwhuis
Posts: 246
Joined: 10 Jun 2008 15:40
Location: Netherlands

Re: BUG: Show All Items In Branch (file size sum)

Post by Sander Bouwhuis »

Ok, I'll do a simplified version of what Muroph suggested:

1. I set the search settings to 'Not directory' and 'Not junction'.
2. Instead of pressing <CTRL>-F3, I'll press <CTRL>-f, then <ENTER>

I've noticed that XYplorer remembers the settings, so next time I start my computer, the settings are still correct. As long as I don't change them, those settings will keep working.

Thank you for the tips.
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: BUG: Show All Items In Branch (file size sum)

Post by jacky »

If you still want to be able to change your search settings regardless, simply assign a KS of your choice to this script:

Code: Select all

settingp 'HideFoldersInList', 1; goto '?* /r';
It first hides folders on List, then triggers the a search identical to the "Show All Items In Branch" menuitem.
Proud XYplorer Fanatic

Sander Bouwhuis
Posts: 246
Joined: 10 Jun 2008 15:40
Location: Netherlands

Re: BUG: Show All Items In Branch (file size sum)

Post by Sander Bouwhuis »

Thanks for the tip, but this doesn't work all that well.

When I go back to normal mode, the folders are still gone. The workaround for that would be to have a second script which shows the folders again. But, that is way to complicated for something that I do multiple times per day. This kind of thing has to work simple/fast.
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: BUG: Show All Items In Branch (file size sum)

Post by jacky »

iycgtptyarvg wrote:When I go back to normal mode, the folders are still gone. The workaround for that would be to have a second script which shows the folders again. But, that is way to complicated for something that I do multiple times per day. This kind of thing has to work simple/fast.
Or you could just add the button "Hide Folders in List" to your toolbar, that way you can always hide/show folders in List with one little click.
Proud XYplorer Fanatic

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: BUG: Show All Items In Branch (file size sum)

Post by TheQwerty »

Scripting can be so fun (and arguably entirely useless) sometimes.. :P

Code: Select all

"Size of All Files in Branch"
    $DECIMAL_PLACES  = 2;     //Number of decimal places to display.
    $ROUND_RESULT    = TRUE;  //Round the result?

    $ADJUST_INCLUDES = TRUE;  //Use different settings than list view
    $INCLUDE_HIDDEN  = TRUE;  //for hidden and
    $INCLUDE_SYSTEM  = TRUE;  //system files.


    Setting("HideFoldersInList", TRUE);
    if ($ADJUST_INCLUDES) {
      Setting("ShowHiddenItems", $INCLUDE_HIDDEN);
      Setting("ShowSystemItems", $INCLUDE_SYSTEM);
    }
    Goto("?* /r");

    $exp = Eval(Report("+{Dir 0|{Size RAW}|0}", 0, "0"));  //Sum the sizes of all the files.

    //Convert from bytes to a more meaningful unit.
    if     ($exp >= 1099511627776) { $suffix = "TB"; $exp = $exp / 1099511627776; }
    elseif ($exp >= 1073741824)    { $suffix = "GB"; $exp = $exp / 1073741824;    }
    elseif ($exp >= 1048576)       { $suffix = "MB"; $exp = $exp / 1048576;       }
    elseif ($exp >= 1024)          { $suffix = "KB"; $exp = $exp / 1024;          }
    else                           { $suffix = "B";                               }

    if ($ROUND_RESULT) {
      $factor = Eval("1" . StrRepeat("*10", $DECIMAL_PLACES));
      $exp = $exp * $factor;
      RegExReplace($last, "$exp", "^.*\.(.).*$", "$1");
      if ($last < 5) { $exp--; }
      $exp++;
      $exp = $exp / $factor;

    } else /*No Rounding*/ {
      RegExReplace($exp, "$exp", "^(.*\..{$DECIMAL_PLACES}).*$", "$1");
    }

    Echo("Sum of file sizes is $exp $suffix");

Post Reply