Solved How to output empty space size in a drive using batch?

August 23, 2014 at 10:26:07
Specs: Windows 64
Im familiar with this command to get the size of a file:
FOR /F "usebackq" %%A IN ('vare1') DO set vare1=%%~zA

I was wondering if there is a way in batch to get the amount of free space left in a drive outputted to a .txt file. Thankyou.


See More: How to output empty space size in a drive using batch?

Report •


#1
August 23, 2014 at 12:22:15
Best place for batch file queries is the Programming forum. I'll ask the mods if they are prepared to shift it there.

Always pop back and let us know the outcome - thanks


Report •

#2
August 24, 2014 at 19:25:32
@fsutil volume diskfree %1: > space%1.txt

to use: xxx C
where xxx is your batchfile name (xxx.bat). Data stored in spaceC.txt

message edited by nbrane


Report •

#3
August 28, 2014 at 09:05:56
✔ Best Answer
FSUTIL requires admin rights, and that means it requires elevation Vista+.

WMIC tends to fail if you're not an admin in WinXP, and its parsing tends to change from one version of Windows to the next.

That leaves DIR.

FOR /F "tokens=3" %a IN ('DIR /-c c:\ ^| FINDSTR /c:"bytes free"') DO SET free=%a
@ECHO %free%

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
August 28, 2014 at 21:22:46
Thanks, R2! I always forget about security/privelage issues.

Report •

#5
August 29, 2014 at 14:52:30
It says "\ was not expected at this time: and when I remove the \, it says "| was not expected at this time" Any ideas as to why?

Report •

#6
August 29, 2014 at 17:59:13
missing percent? from:
FOR /F "tokens=3" %a IN
to:
FOR /F "tokens=3" %%a IN

Report •


Ask Question