Batch File to determine the formatted volume size of a drive in terabytes

Occasional Visitor

I have two portable external drives used for backups on a Windows 11 computer. One drive is approx. 2TB in formatted volume size and the other is approx. 4TB. Each of these is typically around 75% full at any time.


I wish to run a backup batch file to perform the backups, where the batch file determines the formatted volume size in terabytes of the connected external drive. If the external drive's volume size is determined to be less than 3TB (as it will be for the 2TB drive), the selected command line string is run to copy the contents with certain folders excluded. If the external drive's volume size is greater than 3TB (as it will be for the 4TB drive), an alternative command line string is run to copy the contents without exclusions.


My problem is that I don't know how to obtain, from within a batch file, the formatted volume size of a drive and to then convert that to a figure in terabytes, say to two significant digits, such as 1.9.
I'd be grateful for any assistance.
Thanks and regards.

 

0 Replies