Display Sum of Files and Folders' Sizes on both Panes.
Posted: 09 Nov 2010 16:59
This will calculate and display file sizes' sum on both panes, two modes: one will sum up all files (no folders!) on both panes and show the results of each, the other will calculate selected items' (files and folders if any) sizes and display the results for comparison.
-requires XYplorer v +9.70.004;
-has borrowed code that checks for existing dual panes (stealing is an art, boys and girls!
);
-display a great way to execute two scripts out of a description box (thanks for the tips, Stefan!);
-fixes a minor problem regarding residual file sizes displayed for folders;
-tells which value belongs to which pane;
-displays two methods for both dealing with eval and paragraphs on confirm boxes.
EDIT: Compatibility check.
>ToDo: rephrase wording (I feel there's something wrong with that as it is...).
For the sake of pleasant results' displaying, I'd really like to have a way/parameter to show such data with leading zeros auto-filled by XY based on the longer number out of outputs...
Current:
Desired:
-see the difference...? (run those codes on address bar and you'll know what I'm talking about)
-requires XYplorer v +9.70.004;
-has borrowed code that checks for existing dual panes (stealing is an art, boys and girls!
-display a great way to execute two scripts out of a description box (thanks for the tips, Stefan!);
-fixes a minor problem regarding residual file sizes displayed for folders;
-tells which value belongs to which pane;
-displays two methods for both dealing with eval and paragraphs on confirm boxes.
EDIT: Compatibility check.
>ToDo: rephrase wording (I feel there's something wrong with that as it is...).
For the sake of pleasant results' displaying, I'd really like to have a way/parameter to show such data with leading zeros auto-filled by XY based on the longer number out of outputs...
Current:
Code: Select all
::Echo("File sizes on pane 1 are: 234.345 bytes,<crlf> while in the pane 2 are 1.325 bytes.<crlf><crlf>Included size of selected folders too,<crlf>if any.<crlf>-Have a nice day!");
Code: Select all
::Echo("File sizes on pane 1 are: 234.345 bytes,<crlf> while in the pane 2 are 001.325 bytes.<crlf><crlf>Included size of selected folders too,<crlf>if any.<crlf>-Have a nice day!");
Code: Select all
//works on XYplorer v +9.70.004
end (<xyver> < "9.70.0004"), "Sorry - this script requires XYplorer version 9.70.0004 or higher.<crlf>Click 'Ok' to exit.";
$answer = confirm("Sum up sizes of all files only or<br>calculate selected files and folders only?<br>-will work on both panes!<br><br>OK for All Files' sum,<br>Cancel for Selected Files and Folders.")?"_ZERO":"_ONE";
sub $answer;
"_ZERO"
if (get("#800") == "0") {
#800;
}
$pa = <get pane>;
$a = Eval(Report("+{Dir 0|{Size B}|0}", 0, "0"));
focus pi;
$pi = <get pane>;
$b = Eval(Report("+{Dir 0|{Size B}|0}", 0, "0"));
focus pi;
Echo("File sizes on pane $pa are: $a bytes,<crlf> while in the pane $pi are: $b bytes.<crlf>-Have a nice day!");
"_ONE"
if (get("#800") == "0") {
#800;
}
$pa = <get pane>;
#487;
$c= report ("{Size B}+", 1); $t= substr ($c, 0,-1); replace $t, $t, "-","0"; $t= eval ($t);
#485;
focus pi;
$pi = <get pane>;
#487;
$c2= report ("{Size B}+", 1); $t2= substr ($c2, 0,-1); replace $t2, $t2, "-","0"; $t2= eval ($t2);
#485;
focus pi;
// setting "ShowFolderSizeInList", 0;
Echo("File sizes on pane $pa are: $t bytes,<crlf> while in the pane $pi are $t2 bytes.<crlf><crlf>Included size of selected folders too,<crlf>if any.<crlf>-Have a nice day!");