Reputation: 41
I would like a fully automated way of running disk cleanup when fsutil volume diskfree c: returns under, lets say, 50gb. Currently, I have used cleanmgr /sageset:1 and stored my settings, so the process is half automated. But when it returns the amount of space free, is there any way for windows to read this. Keep in mind this will be in a batch file, so I cannot manually view this. Thanks for any help!
Upvotes: 0
Views: 151
Reputation: 41
@echo off
setlocal
set "pad=000000000000000"
set "NeededSpace=%pad%4294967296"
for /f "delims== tokens=2" %%x in (
'wmic logicaldisk where "DeviceID='C:'" get FreeSpace /format:value'
) do for %%y in (%%x) do set "FreeSpace=%pad%%%y"
if "%FreeSpace:~-15%" geq "%NeededSpace:~-15%" echo Drive has at least 4 GB free space.
Upvotes: 1