BrokeDBA

check_freespace.bat

May 28th, 2021 (edited)
1,587
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.75 KB | None | 0 0
  1. REM If you ever want to run a df like command on windows especially for shared drive usage check . use the below batch script .
  2. REM file :check_freespace.bat
  3. REM usage : check_freespace.bat "D:"
  4. @echo off
  5. setlocal EnableDelayedExpansion
  6. for /F "tokens=1* delims=:" %%a in ('fsutil volume diskfree %1 ') do for %%c in (%%b) do (
  7.    set "D=%%c"
  8.    set /A "D1=!D:~0,-8!,D2=1!D:~-8,-4!-10000,D3=1!D:~-4!-10000"
  9.    for /L %%f in (1,1,3) do ( rem Number of divisions: KB, MB, GB
  10.       set /A "F=0,C=0"
  11.       for /L %%i in (1,1,3) do ( rem Quads in the number of bytes: 3*4 = 12 digits
  12.          set /A "F+=^!^!D%%i"
  13.          if !F! neq 0 set /A "D=C*10000+D%%i,D%%i=D/1024,C=D%%1024"
  14.       )
  15.    )
  16.    set /A "C=C*10000/1024+10000
  17.    echo %%a: !D3!.!C:~1,2! GB
  18. )
Add Comment
Please, Sign In to add comment