Page 1 of 1

how to convert by to Kb, MB or GB

Posted: Wed Dec 07, 2016 6:49 pm
by Laurent.madjarian
Hi everybody,

is there a way to convert byte from %i_original_size% to KiloByte, MegaByte or GigaByte ?


Best,
Laurent.

Re: how to convert by to Kb, MB or GB

Posted: Thu Dec 08, 2016 9:47 pm
by Laurent.madjarian
Ok i wrote a simple vbscript to convert %original_size% from byte to KB,MB,GB or TB,
but i dont know how to retreive the result from a command processor ?

in case the script is here:

Code: Select all

' convert byte to KB,MB,GB or TB for ffastrans
' call from command line with cscript byteconvert.vbs %original_size%

val = WScript.Arguments.Item(0)
mult = 1024

If val > mult Then
val = val/mult
unit = " KB"

If val > mult Then
val = val/mult
unit = " MB"

If val > mult Then
val = val/mult
unit = " GB"

If val > mult Then
val = val/mult
unit = " TB"

End If
End If
End If
End If

cscript.echo int(val) & unit

Re: how to convert by to Kb, MB or GB

Posted: Sun Dec 11, 2016 11:57 am
by admin
You can use a combination of "Contitional"-nodes to evaluate the size and then use the "Populate"-nodes and math expressions to create integer variables containing the new rounded value in KB, MB or GB.

-steinar