WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: seckner on July 31, 2014, 12:27:53 PM

Title: DiskSize and TB drives
Post by: seckner on July 31, 2014, 12:27:53 PM
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!
Title: Re: DiskSize and TB drives
Post by: td on July 31, 2014, 01:31:01 PM
You need to be more specify. What exactly do you want to do with your terabyte sized drives?
Title: Re: DiskSize and TB drives
Post by: seckner on August 01, 2014, 04:57:05 AM
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? 
Title: Re: DiskSize and TB drives
Post by: td on August 01, 2014, 06:56:31 AM
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
Title: Re: DiskSize and TB drives
Post by: seckner on August 01, 2014, 09:04:37 AM
Tony - Thank You! I even understand it!