Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Batch File Help - If Statement

23 May 2011   #1

Windows 8.1 Pro x64
 
 
Batch File Help - If Statement

Hi,

I have the following batch file that works great, it tells me an approx amount of MB and GB of space left on c:\

Code:
@echo off
cls

for /f "tokens=1-3" %%n in ('"WMIC LOGICALDISK GET Name,Size,FreeSpace | find /i "C:""') do set free=%%n& set total=%%p
rem echo.
rem echo %free% bytes free

set free=%free:~0,-3%
set /a free=%free%/1049
echo C: Space Free- %free% MB (approx)

set /a free=%free%/1024
echo C: Space Free- %free% GB (approx)


pause
I would now like an IF statement to do the same IF there is a D:\ but only if a D:\ exists otherwise ignore and move on

I can add the following to the bottom of it that would then do the d:\ but i don't know how to put an IF statement around it?

Code:
for /f "tokens=1-3" %%n in ('"WMIC LOGICALDISK GET Name,Size,FreeSpace | find /i "D:""') do set free=%%n& set total=%%p
rem echo.
rem echo %free% bytes free

set free=%free:~0,-3%
set /a free=%free%/1049
echo C: Space Free- %free% MB (approx)

set /a free=%free%/1024
echo C: Space Free- %free% GB (approx)


pause
Regards,
JDobbsy1987


My System SpecsSystem Spec
.

Reply

 Batch File Help - If Statement




Thread Tools




Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:44 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33