Disks is a simple alias for displaying system disk usage. It also demonstrates a bit of 'spaghetti code' with a /goto label jump.
Output
* disks: C:\ | used: 234GB ( 79%) | free: 63.6GB ( 21%) | size: 297GB | (no label) (fixed)
* disks: E:\ | used: 1.81TB (100%) | free: 9.22GB ( 0%) | size: 1.82TB | 2TB External (fixed)
* disks: G:\ | used: 917GB ( 99%) | free: 13.7GB ( 1%) | size: 931GB | Toshiba Ext HDD (fixed)
* disks: H:\ | used: 4.00GB ( 27%) | free: 10.9GB ( 73%) | size: 14.9GB | READYBOOST (removable)
* disks: ----+---------------------+---------------------+--------------+------------------------
* disks: (4) | used: 2.94TB ( 97%) | free: 97.5GB ( 3%) | size: 3.03TB | System Total
mIRC Script (Aliases section)
; Usage: /disks (or) /disks all
disks { ; by Raccoon 2015
linesep
var %i = 1, %usedt, %freet, %sizet, %disks, %all, %jump
if ($1 == all) var %all = $true
while ($disk(%i).type) {
var %type = $v1, %path = $disk(%i).path, %unc = $disk(%i).unc
var %label = $iif($disk(%i).label,$v1,(no label))
var %free = $disk(%i).free, %size = $disk(%i).size, %used = $calc(%size - %free)
:disksjump
var %freeb = $padr($bytes(%free,3).suf,6)
var %sizeb = $padr($bytes(%size,3).suf,6)
var %usedb = $padr($bytes(%used,3).suf,6)
var %freep = $padr($round($calc(%free / %size * 100),0) $+ %,4)
var %usedp = $padr($round($calc(%used / %size * 100),0) $+ %,4)
if ($disk(%i)) || (%all) || (%jump) {
inc %usedt %used | inc %freet %free | inc %sizet %size | inc %disks
echo -atic info * disks: %path $(|) $&
used: %usedb ( $+ %usedp $+ ) $(|) $&
free: %freeb ( $+ %freep $+ ) $(|) $&
size: %sizeb $(|) $&
$iif(%jump, System Total, %label ( $+ %type $+ ) %unc)
}
inc %i
}
if (%disks) && (!%jump) {
echo -atic info * disks: $+($str(-,4),+,$str(-,21),+,$str(-,21),+,$str(-,14),+,$str(-,24))
var %free = %freet, %used = %usedt, %size = %sizet, %path = ( $+ %disks $+ )
var %jump = $true
goto disksjump
}
linesep
}
padr { return $str($iif($3 != $null,$3,$chr(160)),$calc($2 - $len($1))) $+ $1 } ; by Raccoon 2015
(Update) Expanding a little further, I decided to add a column showing the percentage of the relative size of each disk. This required advanced knowledge of the total bytes of every disk prior to main iteration loop, so a second loop is added and %sizet
is quickly tallied. Sure, it'd be possible to collect all disk vitals before echoing the output, but that would mean creating arrays to save each parcel of information... maybe not worth it.
* disks: C:\ | used: 231GB ( 78%) | free: 66.4GB ( 22%) | size: 297GB ( 10%) | (no label) (fixed)
* disks: E:\ | used: 1.81TB (100%) | free: 9.22GB ( 0%) | size: 1.82TB ( 60%) | 2TB External (fixed)
* disks: G:\ | used: 920GB ( 99%) | free: 10.6GB ( 1%) | size: 931GB ( 30%) | Toshiba Ext HDD (fixed)
* disks: H:\ | used: 4.00GB ( 27%) | free: 10.9GB ( 73%) | size: 14.9GB ( 0%) | READYBOOST (removable)
* disks: ----+---------------------+---------------------+---------------------+------------------------
* disks: (4) | used: 2.94TB ( 97%) | free: 97.3GB ( 3%) | size: 3.03TB (100%) | System Total
; Usage: /disks (or) /disks all
disks { ; by Raccoon 2015
linesep
var %i = 1, %sizet
while ($disk(%i).type) { if ($disk(%i)) inc %sizet $disk(%i).size | inc %i }
var %i = 1, %usedt, %freet, %disks, %all, %jump
if ($1 == all) var %all = $true
while ($disk(%i).type) {
var %type = $v1, %path = $disk(%i).path, %unc = $disk(%i).unc
var %label = $iif($disk(%i).label,$v1,(no label))
var %free = $disk(%i).free, %size = $disk(%i).size, %used = $calc(%size - %free)
:disksjump
var %freeb = $padr($bytes(%free,3).suf,6)
var %usedb = $padr($bytes(%used,3).suf,6)
var %sizeb = $padr($bytes(%size,3).suf,6)
var %freep = $padr($round($calc(%free / %size * 100),0) $+ %,4)
var %usedp = $padr($round($calc(%used / %size * 100),0) $+ %,4)
var %sizep = $padr($round($calc(%size / %sizet * 100),0) $+ %,4)
if ($disk(%i)) || (%all) || (%jump) {
inc %usedt %used | inc %freet %free | inc %disks
echo -atic info * disks: %path $(|) $&
used: %usedb ( $+ %usedp $+ ) $(|) $&
free: %freeb ( $+ %freep $+ ) $(|) $&
size: %sizeb ( $+ %sizep $+ ) $(|) $&
$iif(%jump, System Total, %label ( $+ %type $+ ) %unc)
}
inc %i
}
if (%disks) && (!%jump) {
echo -atic info * disks: $+($str(-,4),+,$str(-,21),+,$str(-,21),+,$str(-,21),+,$str(-,24))
var %free = %freet, %used = %usedt, %size = %sizet, %path = ( $+ %disks $+ )
var %jump = $true
goto disksjump
}
linesep
}
padr { return $str($iif($3 != $null,$3,$chr(160)),$calc($2 - $len($1))) $+ $1 } ; by Raccoon 2015
doesn't seem to show my hd info =(
Wow, that's really big :) Huh, I don't know why it's not working for you. mIRC 7.41?