Results 1 to 3 of 3

Thread: Batch file to get available disk space in Windows XP

  1. #1
    Join Date
    Nov 2008
    Posts
    1,185

    Batch file to get available disk space in Windows XP

    I am running Windows XP Pro on my computer with Seagate 160 GB hard disk. My hard disk is occupied very much. Now I want to store a 1GB movie on my drive but it is failing. When I see the available disk space, I come to know that I have that much of space. So why is that failing? Can I have a batch file that can run in Windows XP to get the available disk space on my computer which I can use?

  2. #2
    Join Date
    Aug 2008
    Posts
    1,238

    Re: Batch file to get available disk space in Windows XP

    Although you are getting 1GB free disk space, some part of your hard disk might be used by your system, Windows XP, or graphics card depending on your settings. However you can try the below batch code to get the available disk space:

    Code:
    @echo off
    setLocal EnableDelayedExpansion
    
    for /f "tokens=3 delims= " %%A in ('dir /s/-c \ ^|find "File(s)"') do (
    set /a myFile=%%A/1000000
    )
    for /f "tokens=3 delims= " %%A in ('dir /s/-c ^|find "bytes free"') do (
    set /a FREE=%%A/1000000
    )
    
    echo used: !myFile!MB
    echo free: !FREE!MB
    set /a TOTAL=!myFile!+!FREE!
    echo total disk space: !TOTAL!MB
    set /a pcUSED=(!myFile!*100)/!TOTAL!
    echo percent used: !pcUSED!

  3. #3
    Join Date
    May 2008
    Posts
    1,395

    Re: Batch file to get available disk space in Windows XP

    I am not much in batch file coding but the basic idea would be something like this:

    Code:
    @echo off
    dir >freespace.txt
    FOR /f "skip=3 delims=" %%a in ('find "Bytes free" c:\freespace.txt') do echo %%a >freespace.txt
    
    FOR /f "tokens=1-4 skip=3 delims= " %%a in ('find "." freespace.txt') do echo %%a

Similar Threads

  1. Junk file consume 50% of my disk space in Mac Mini
    By Eas!war in forum Operating Systems
    Replies: 7
    Last Post: 23-03-2015, 06:35 PM
  2. Windows Batch file to output directory names and size to txt file
    By m2thearkus in forum Software Development
    Replies: 6
    Last Post: 16-07-2010, 12:04 AM
  3. How can I play a sound file from a Windows batch file?
    By Linoo in forum Operating Systems
    Replies: 4
    Last Post: 27-03-2010, 07:20 PM
  4. Allocating disk space On Windows Xp
    By B_Hodge in forum Operating Systems
    Replies: 3
    Last Post: 11-06-2009, 05:53 PM
  5. Windows add ons for disk space monitor
    By Caddo in forum Customize Desktop
    Replies: 4
    Last Post: 31-01-2009, 10:00 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,043,306.76036 seconds with 17 queries