Page 1 of 1

Drive space left shown in menu

Posted: 23 Aug 2020 00:11
by Eep²
Years (probably at least a decade now) ago I used Directory Opus and it's drives toolbar showed each drive's free space without having to right-click on the drive and choose properties or left-click the drive to go to it and see the space left in the status bar. Is there a way to have XYplorer show a drive's free space in its "System" toolbar menu?

Re: Drive space left shown in menu

Posted: 08 Sep 2020 23:02
by Eep²
I guess not possible?

Re: Drive space left shown in menu

Posted: 09 Sep 2020 00:26
by highend
You mean show it "all the time" without user interaction? No.

A bit easier maybe:

Code: Select all

    $drives = get("drives", , <crlf>);
    $log = "";
    foreach($drive, $drives, <crlf>, "e") {
        //$name = get("drivename", $drive, 0);
        $free = formatbytes(get("freespace", $drive, 1));
        //$log .= $drive . " - " . $name . " [Free: " . $free . "]" . <crlf>;
        $log .= $drive . " [Free: " . $free . "]" . <crlf>;
    }
    $sel = popupmenu($log, 6:=<crlf>);
    if ($sel) { goto gettoken($sel, 1, " "); }

Re: Drive space left shown in menu

Posted: 10 Sep 2020 01:53
by Eep²
Thanks, highend, but the script window gives "The device is not ready." when I run your script.

Re: Drive space left shown in menu

Posted: 10 Sep 2020 05:28
by highend
Show a screenshot of that message and which kind of drive is that (removable, CD-ROM, mapped drive, ...)?

Re: Drive space left shown in menu

Posted: 10 Sep 2020 09:59
by RalphM
I get the same message twice, once for a BD-RE drive (E:/ w/o a disc inserted) and the second for a mapped external drive which is currently not connected to my NAS (N:/) and results in the following pop-up:
PicPick_530.jpg
PicPick_530.jpg (30.03 KiB) Viewed 2126 times

Re: Drive space left shown in menu

Posted: 10 Sep 2020 10:06
by highend
Run

Code: Select all

text get("drives", 0, <crlf>);
text get("drives", 1, <crlf>);
...
text get("drives", 6, <crlf>);
In other words from 0 up to 6 one after another and tell me
if E:\ is listed when you use 2 (and not anywhere else)
and on which value you see the N:\ drive

Re: Drive space left shown in menu

Posted: 10 Sep 2020 10:57
by RalphM
0 -> None
1 -> N:/
2 -> None
3 -> C:/ and D:/
4 -> G:/, M:/ and Z:/ (all mapped drives on the same NAS)
5 -> E:/
6 -> None

Re: Drive space left shown in menu

Posted: 10 Sep 2020 11:02
by highend
Ok,

then use this one and if you don't have drives of that types or don't want to query them, set their value to false instead of true:

Code: Select all

    $useRemovable = true;
    $useRemote    = true;

    $drives = get("drives", 3, <crlf>); // Fixed drives
    if ($useRemovable) { $drives .=  <crlf> . get("drives", 2, <crlf>); }
    if ($useRemote)    { $drives .=  <crlf> . get("drives", 4, <crlf>); }
    $drives = formatlist($drives, "sed", <crlf>);

    $log = "";
    foreach($drive, $drives, <crlf>, "e") {
        //$name = get("drivename", $drive, 0);
        $free = formatbytes(get("freespace", $drive, 1));
        //$log .= $drive . " - " . $name . " [Free: " . $free . "]" . <crlf>;
        $log .= $drive . " [Free: " . $free . "]" . <crlf>;
    }
    $sel = popupmenu($log, 6:=<crlf>);
    if ($sel) { goto gettoken($sel, 1, " "); }

Re: Drive space left shown in menu

Posted: 10 Sep 2020 11:36
by RalphM
Works good enough for me and doesn't give any error messages anymore even with "$useRemovable = true".
Let's hear if the OP is happy as well, as I was just helping with my results.

Re: Drive space left shown in menu

Posted: 10 Sep 2020 23:03
by Eep²
Yes, that works; thanks. Now I'll try to figure out how to add total space and see if there's a way to have it always show in the toolbar instead of having to click a button...

Trying to add used space but all that happens is "Drives" pops up. Any ideas what I'm doing wrong?

Code: Select all

    $useRemovable = true;
    $useRemote    = true;

    $drives = get("drives", 3, <crlf>); // Fixed drives
    if ($useRemovable) { $drives .=  <crlf> . get("drives", 2, <crlf>); }
    if ($useRemote)    { $drives .=  <crlf> . get("drives", 4, <crlf>); }
    $drives = formatlist($drives, "sed", <crlf>);

    $log = "";
    foreach($drive, $drives, <crlf>, "e") {
        //$name = get("drivename", $drive, 0);
        $free = formatbytes(get("freespace", $drive, 1));
        $used = formatbytes(get("usedspace", $drive, 1));
        //$log .= $drive . " - " . $name . " [Free: " . $free . "]" . <crlf>;
        $log .= $drive . " [Used: " . $used . ", " . Free: " . $free . "]" . <crlf>;
    }
    $sel = popupmenu($log, 6:=<crlf>);
    if ($sel) { goto gettoken($sel, 1, " "); }
I'd also like to have the drive volume name show in the list.

Re: Drive space left shown in menu

Posted: 10 Sep 2020 23:08
by highend
get() knows "usedspace" as well...
if there's a way to have it always show in the toolbar instead of having to click a button...
That's not possible with XY scripting. You would need to write an external tool for this

Re: Drive space left shown in menu

Posted: 11 Sep 2020 00:23
by klownboy
You were missing a quote. This adds drivename to the listing.

Code: Select all

    $useRemovable = true;
    $useRemote    = true;

    $drives = get("drives", 3, <crlf>); // Fixed drives
    if ($useRemovable) { $drives .=  <crlf> . get("drives", 2, <crlf>); }
    if ($useRemote)    { $drives .=  <crlf> . get("drives", 4, <crlf>); }
    $drives = formatlist($drives, "sed", <crlf>);

    $log = "";
    foreach($drive, $drives, <crlf>, "e") {
        //$name = get("drivename", $drive, 0);
        $free = formatbytes(get("freespace", $drive, 1));
        $used = formatbytes(get("usedspace", $drive, 1));
        $drivename = get("drivename", $drive,"0");
        //$log .= $drive . " - " . $name . " [Free: " . $free . "]" . <crlf>;
       // $log .= $drive . " [Used: " . $used . ", " . " Free: " . $free . "]" . <crlf>;
        $log .= $drive . " (" . $drivename . ")" . " [Used: " . $used . ", " . " Free: " . $free . "]" . <crlf>;
    }
    $sel = popupmenu($log, 6:=<crlf>);
    if ($sel) { goto gettoken($sel, 1, " "); }

Re: Drive space left shown in menu

Posted: 13 Sep 2020 18:25
by Eep²
Thanks.