Solved

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

Posted on 2004-09-03
7
484 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

726 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