Viewing 1 post (of 1 total)
• Author
Posts
• #10923
Stefan
Participant

Do you want to create new partitions
with exactly n GB but you have to enter this in MB unit
because the Disk Management wants to get MB only?

If yes, this script will aid you.
It calculates the MB size from the entered GB (or TB) size:

Basically it’s just a simple math:
n GB = n*1024 MB
n TB = n*1024*1024 MB

But since EmEditor is open anyway,
he can do the math for me:

```
//Calculate HDD Size in MB from entered GB
//  for creating new partitions in correct wanted size
//    because the Disk Management works with MB only

vInput = prompt("Enter GB size (add a 'T' for TB input) to calculate to MB :", "80");

vInput = vInput.toUpperCase();
vTest =  vInput.replace(/[A-Z ]/g,"");
if(vTest.length < 1){alert("Missing the size?nUse e.g. 80 for 80GB or 80t for 80TB");quit();}

vInput = vInput.replace(/[A-FH-SU-Z ]/g,"");

if(vInput.indexOf("G") > 0){
vInput = vInput.replace(/[A-Z ]/g, "");
vResult = vInput * 1024;
alert(vInput + " GB = " + vResult + " MB");
}else
if(vInput.indexOf("T") > 0){
vInput = vInput.replace(/[A-Z ]/g, "");
vResult = vInput * 1024 * 1024;
alert(vInput + " TB = " + vResult + " MB");
}else{
vInput = vInput.replace(/[A-Z ]/g, "");
vResult = vInput * 1024;
alert(vInput + " GB = " + vResult + " MB");
}
```

// 10 GB = 10240 MB
// 80 GB = 81920 MB
// 100 GB = 102400 MB
// 250 GB = 256000 MB
// 300 GB = 307200 MB
// 400 GB = 409600 MB
// 500 GB = 512000 MB
// 555 GB = 568320 MB
//1000 GB = 1024000 MB
//1024 GB = 1048576 MB
// 1 TB = 1048576 MB
// 80 TB = 83886080 MB

Viewing 1 post (of 1 total)
• You must be logged in to reply to this topic.