How to get total size of a disk or partition(a USB hard drive with 1 NTFS partition) in a batch file?
I would rather not go for logic that go over files recursively(the ones with for /f) since it's a 1TB drive and it may take a long time to determine size.
I am open to use some small third party tool which will return size to batch file.
PS: I am on Windows 7 x64 Ultimate
Best Answer
There is probably an easier way to do this, but here is what I use
If all you want is the bytes, you can just do this command change T to the drive letter of your external (for a one liner at command prompt change
%%
to%
andset space=
toecho
)if you want to then take that and simplfy it, first set guidelines for each size
Then write a temporary VBS script as batch can't handle the math
Run it, capture result and delete it
Then the following trims the result to two decimal places
Echo results
[EDIT]
For total size, you can use diskpart list volume (change
"%%a"=="T"
to"%%a"=="driveletterhere"
)and bonus how you could calculate that: