Posted By

DaveChild on 09/11/08


Tagged

freespace


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

darkapple
Tyster


DOS Calculate Free Space on Drive


 / Published in: DOS Batch
 

Run this from within SQL Server to get free space on a drive into a table.

See http://snipplr.com/view/8339/write-disk-space-to-table/ for SQL.

  1. @echo off >nullfile.txt
  2. set Drive=C:
  3. for /F "tokens=7" %%a in ('fsutil volume diskfree %Drive% ^| find /i "# of free"') do set free=%%a
  4. set free=%free:~0,-6%
  5. echo c: %free%

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Barney on July 21, 2009

This DOS batch job works a treat, but would like to fine tune further if possible. When I run this I get free disk space figures like for example 1987654321 (=1.98gb) or 21987654321 (=21.98gb) or 321987654321 (=321.98gb). Ideally I want to break down the free disc space return value into a MB or GB figure, as I have shown above. Can anyone help? Secondly need a similar DOS batch to shown me disk size.

Posted By: Barney on July 21, 2009

This DOS batch job works a treat, but would like to fine tune further if possible. When I run this I get free disk space figures like for example 1987654321 (=1.98gb) or 21987654321 (=21.98gb) or 321987654321 (=321.98gb). Ideally I want to break down the free disc space return value into a MB or GB figure, as I have shown above. Can anyone help? Secondly need a similar DOS batch to shown me disk size.

Posted By: Barney on July 21, 2009

This DOS batch job works a treat, but would like to fine tune further if possible. When I run this I get free disk space figures like for example 1987654321 (=1.98gb) or 21987654321 (=21.98gb) or 321987654321 (=321.98gb). Ideally I want to break down the free disc space return value into a MB or GB figure, as I have shown above. Can anyone help? Secondly need a similar DOS batch to shown me disk size.

You need to login to post a comment.