DiskSize and TB drives

Started by seckner, July 31, 2014, 12:27:53 PM

Previous topic - Next topic

seckner

I'm sorry if this has already been brought up - but how do I deal with TB sized drives? A long time ago I found some code to help convert the size to GB:

   If Val > 1000000000                                   ; GB
      NewVal = Val / 1024000000.0     
      NewVal = StrCat( NewVal, " GB" )
   EndIf

Math really isn't a strong point. Thanks for your help!

td

You need to be more specify. What exactly do you want to do with your terabyte sized drives?
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

seckner

Apologies - dragging a bit. The script gets the total disk size, disk used and percent free - and with help and borrowed code any disk under a TB reports correctly. At a TB however I am receiving figures like .02% free on a disk that's 1.5 TB in size and 70% free. In the code piece I included I finally figured that adding 3 more zeros to "NewVal = Val / 1024000000.0" changed GB to TB and it seems to work and shows the disk size and used space pretty close to what Windows reports. Where I'm lost is getting the percent free space: 1.5 TB size and 600 Gig used - how can I turn that into percent free? 

td

Code (winbatch) Select

nSize = 1.5
nUsed = 600

; Normalize units by convertint TiB to GiB.
nSize *= 1024.0 ; Use nSize = nSize * 1024.0 pre WinBatch 2014B

; Caculate the percentage used space.
nPrcnt = nUsed / nSize
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

seckner

Tony - Thank You! I even understand it!