Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Disk capacity

26 views
Skip to first unread message

Tom Del Rosso

unread,
Jul 16, 2011, 8:48:41 PM7/16/11
to
Can you get the total capacity of a disk using native utils (without the
intense operation of listing all directories and adding the total used to
the free space)?

Thanks.


--
Reply in group, but if emailing add one more
zero, and remove the last word.


foxidrive

unread,
Jul 16, 2011, 9:47:07 PM7/16/11
to
On 17/07/2011 10:48, Tom Del Rosso wrote:
> Can you get the total capacity of a disk using native utils (without the
> intense operation of listing all directories and adding the total used to
> the free space)?
>
> Thanks.
>

It depends on the OS being used.


--
Regards,
Mic

Tom Del Rosso

unread,
Jul 16, 2011, 10:00:09 PM7/16/11
to

From XP forward. The 2k utilities are a little different, but I don't
really deal with 2k much any more so it's best to forget it. If it can't be
done natively, then utilities from either the resource kit or support tools
or sysinternals are ok.

foxidrive

unread,
Jul 16, 2011, 10:23:28 PM7/16/11
to
On 17/07/2011 12:00, Tom Del Rosso wrote:
> foxidrive wrote:
>> On 17/07/2011 10:48, Tom Del Rosso wrote:
>>> Can you get the total capacity of a disk using native utils (without
>>> the intense operation of listing all directories and adding the
>>> total used to the free space)?
>>>
>>> Thanks.
>>>
>>
>> It depends on the OS being used.
>
> From XP forward. The 2k utilities are a little different, but I don't
> really deal with 2k much any more so it's best to forget it. If it can't be
> done natively, then utilities from either the resource kit or support tools
> or sysinternals are ok.


I'm just giving a pointer here - try this. Wmic is not available on XP Home AFAIK.

@echo off
Wmic path Win32_DiskDrive get /value >file.txt



--
Regards,
Mic

foxidrive

unread,
Jul 16, 2011, 10:33:22 PM7/16/11
to


And here is a sample using diskpart. It needs admin access or maybe backup permissions I think.


@echo off
del script.txt 2>nul
>>script.txt echo select disk 0
>>script.txt echo detail disk
>>script.txt echo exit
diskpart /s script.txt >details.txt
del script.txt 2>nul

What is the purpose for finding the drive size? Is it merely to list all drives and capacities in the machine?

--
Regards,
Mic

Tom Del Rosso

unread,
Jul 17, 2011, 12:43:05 AM7/17/11
to

foxidrive wrote:
>
> And here is a sample using diskpart. It needs admin access or maybe
> backup permissions I think.
>
> @echo off
> del script.txt 2>nul
> > > script.txt echo select disk 0
> > > script.txt echo detail disk
> > > script.txt echo exit
> diskpart /s script.txt >details.txt
> del script.txt 2>nul

That's a good one. Thanks.


> What is the purpose for finding the drive size? Is it merely to list
> all drives and capacities in the machine?

No, just to report the size of a backup drive in the emails that my backup
script sends to me.

Timo Salmi

unread,
Jul 17, 2011, 8:30:54 AM7/17/11
to
On 17.07.2011 03:48 Tom Del Rosso <td...@verizon.net.invalid> wrote:
> Can you get the total capacity of a disk using native utils (without the
> intense operation of listing all directories and adding the total used to
> the free space)?

170} How do I get the total size of a volume, not just the available
space?
http://www.netikka.net/tsneti/info/tscmd170.htm

All the best, Timo

--
Prof. Timo Salmi, Vaasa, Finland
http://www.netikka.net/tsneti/homepage.php
Useful CMD script tricks http://www.netikka.net/tsneti/info/tscmd.php

Todd Vargo

unread,
Jul 17, 2011, 9:18:37 AM7/17/11
to

"Tom Del Rosso" <td...@verizon.net.invalid> wrote in message
news:ivtp8r$dmg$1...@dont-email.me...

>
> foxidrive wrote:
>>
>> And here is a sample using diskpart. It needs admin access or maybe
>> backup permissions I think.
>>
>> @echo off
>> del script.txt 2>nul
>> > > script.txt echo select disk 0
>> > > script.txt echo detail disk
>> > > script.txt echo exit
>> diskpart /s script.txt >details.txt
>> del script.txt 2>nul
>
> That's a good one. Thanks.

You may like the output from this too.

@echo off
echo list volume >script.txt
echo exit >>script.txt
diskpart /s script.txt >drvlist.txt
del script.txt


Robert Roland

unread,
Jul 17, 2011, 10:28:58 AM7/17/11
to
On Sat, 16 Jul 2011 20:48:41 -0400, "Tom Del Rosso"
<td...@verizon.net.invalid> wrote:

>Can you get the total capacity of a disk using native utils

If you consider VBscript native, you can do this:

set fso = createobject("Scripting.FileSystemObject")
set drive = fso.GetDrive("C:")
wscript.echo "Size: " & drive.TotalSize/(1024^4) & " TB"

There are a few ways to integrate vbscripts into batch. Which one is
best depends on the specific task and your requirements.
--
RoRo

ten.n...@virgin.net

unread,
Jul 18, 2011, 12:10:25 PM7/18/11
to
Although it was touched on by foxidrive earlier, here's how I'd do it with
WMIC.

::----- START -----
WMIC LogicalDisk WHERE "DriveType>='2' OR DriveType<='6'" GET
DeviceID,Size
::------ END ------

Dr J R Stockton

unread,
Jul 18, 2011, 1:31:54 PM7/18/11
to
In alt.msdos.batch.nt message <ivtbha$d7p$1...@dont-email.me>, Sat, 16 Jul
2011 20:48:41, Tom Del Rosso <td...@verizon.net.invalid> posted:

>Can you get the total capacity of a disk using native utils (without the
>intense operation of listing all directories and adding the total used to
>the free space)?

It will not change very often. So perhaps the simplest way is to use a
utility called Windows, My Computer, select drive, Properties (or
something like that) to find the capacity, and to write the number that
it shows in a small file in the root or other directory that your code
can read. The file can also contain other useful information which the
OS is unlikely to know, such as the colour of a thumb drive. Give the
file a suitable name, such as OWNED-BY, put your name in it, and you
stand a better chance of recovering it if it should become lost.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk DOS 3.3 6.20 ; WinXP.
Web <http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.

Tom Del Rosso

unread,
Jul 18, 2011, 11:51:42 PM7/18/11
to

ten.n...@virgin.net wrote:
> Although it was touched on by foxidrive earlier, here's how I'd do it
> with WMIC.
>
> > :----- START -----
> WMIC LogicalDisk WHERE "DriveType>='2' OR DriveType<='6'" GET
> DeviceID,Size
> > :------ END ------

That's very nicely formatted.

0 new messages