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

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
marxbalzAsked:
Who is Participating?
 
sirbountyConnect With a Mentor Commented:
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
 
RobnhoodCommented:
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
 
sirbountyCommented:
What operating system are you using?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
marxbalzAuthor Commented:
WINDOWS 2000 ADVANCED SERVER and some NT 4.0 Servers also.
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
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
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
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
 
sirbountyCommented:
Thanx.  Happy to help! : )
0
All Courses

From novice to tech pro — start learning today.