Solved

How to Assign Drive Space total\used to a variable?

Posted on 2004-09-03
7
453 Views
Last Modified: 2011-09-20
Hi Gurus,
   How do i assign the Drive capacity and space used to a variable from a DOS batch file? Do we have a command
that would do this.

Any input would be appreciated.

thank you
0
Comment
Question by:marxbalz
7 Comments
 
LVL 1

Expert Comment

by:Robnhood
ID: 11972776
I can get use

dir /s | find "bytes free"

to display available disk space, but I am not sure where to take this from here.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 11972846
What operating system are you using?
0
 

Author Comment

by:marxbalz
ID: 11972977
WINDOWS 2000 ADVANCED SERVER and some NT 4.0 Servers also.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 11973680
for /f "usebackq tokens=3 delims= " %i in (`dir ^| find "bytes free"`) do @set FreeSpace=%i

This will set the environment variable "freespace" equal to the free space value returned by dir
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 11973710
Important to note if you are not familiar with the for command, that the single quotes just inside the parenthesis are backquotes - the unshifted ~ on most US keyboards
backquote=`
apostrophe='
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 250 total points
ID: 11973756
You can gain both from chkdsk, although it will take a few moments to run the command:


::-----begin code-----
@echo off
for /f "skip=19 tokens=1,3-4" %%a in ('chkdsk /i /c') do (
if %%b%%c==totaldisk set totDisk=%%a
if %%b%%c==inuse set inUse=%%a
)
::-----end code-------
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 11976025
Thanx.  Happy to help! : )
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Windows 7 does not have the best desktop search built in. This is something Windows 7 users have struggled with. You type something in, and your search results don’t always match what you are looking for, or it doesn’t actually work at all. There ar…
#Citrix #POC #XenDesktop #vCenter #VMware #ESX
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now