Portfolio

FREESPACE SCRIPT

Posted in MIRC with 1286 views.

A simple script that calculates your disk space from your disk arrays of your computer.

I was bored one day and as a person who loves numbers, I would like to see all my harddrives from one simple command. So I spend couple of minutes to do this simple alias that calculates your diskspace of your computer.

It is self explantory, and it there is a menu for it as well when you right click on a query or a channel.

Feel free to take this code!

CODE:
; **/
; * Shows the space!
; * 
; * @author Mohamed Mansour
; * @since 5/12/2006
; * @build 0.1
; */
alias Tools.ShowAllSpace {

  ;// Initializations
  var %output = FREE SPACE: $chr(32)
  var %diskarray = $disk(0)
  var %currarray = 1
  var %tspace =  0
  var %fspace =  0

  ;// Lets loop through the Disk Array
  while ( %currarray <= %diskarray ) {

    ;// Current Disk Array Stats
    var %totalspace =  $disk( $+ %currarray $+ ).size
    var %freespace =  $disk( $+ %currarray $+ ).free
    var %currspace =  $calc(%totalspace - %freespace)
    var %currpath = $remove($disk( $+ %currarray $+ ).path ,\)
    var %label = $disk( $+ %currarray $+ ).label

    ;// Only record the non zero arrays
    if ( %freespace != 0 ) {

      ;// Lets record the the total disk space
      %tspace = $calc( %tspace + $disk( $+ %currarray $+ ).size )
      %fspace = $calc( %fspace + $disk( $+ %currarray $+ ).free )

      ;// Here is the output buffer
      %output = $+(%output, $chr(32) %currpath $chr(32)) 
      %output = $+(%output, ( $+ %label $+ ) $bytes(%freespace,G))
      %output = $+(%output, $+ / $+ $bytes(%totalspace,G) gb) 
    }

    ;// Lets Goto the next Disk Array
    %currarray = $calc(%currarray + 1)
  }

  var %percentage = $int($calc( %fspace / %tspace * 100 ))

  ;// Lets add the total Disk Array count
  %output = $+(%output,$chr(32) Total Free: $bytes(%fspace,G) $+ gb)
  %output = $+(%output,( $+ %percentage $+ % $+ ) free out of $bytes(%tspace,G))
  %output = $+(%output, gb)

  ;// Message out the buffer to Channel or Query
  /MSG $active $1
}

;// ### Menu
menu query,channel {
  -
  Total Space: /Tools.ShowAllSpace 
  -
}

Download here: freespace.mrc