We Recommend

The Rails Way The Rails Way
Now, for the first time, there’s a comprehensive, authoritative guide to building production-quality software with Rails. Pioneering Rails developer Obie Fernandez and a team of experts illuminate the entire Rails API, along with the Ruby idioms, design approaches, libraries, and plug-ins that make Rails so valuable.


Posted By

DaveChild on 09/11/08


Tagged

freespace


Versions (?)


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.