@echo off
REM ============================
REM Fichier : espace_libre.bat
REM Desc : utilisation simple de awk.exe pour calculer l'espace libre restant sur les partitions en dur
REM ============================
cls
echo -------------------------
echo Disques fixes (C D F)
echo -------------------------
for /d %%i in (C D F) do call :traiter1 %%i
echo.
REM echo -----------------------
REM echo Disques amovibles (L M)
REM echo -----------------------
REM for /d %%i in (L M) do call :traiter1 %%i
echo.
echo { total=total+$3/1000000000 } > dirg.awk
echo END { print " ----> " total " Go libres <----"} >> dirg.awk
if exist tmp_dir.txt del tmp_dir.txt
for /d %%i in (C D F) do dir /-c %%i:\|findstr libres >> tmp_dir.txt
awk -f dirg.awk tmp_dir.txt
echo.
pause
goto fin
:traiter1
dir %1:|findstr libres
goto fin
:fin
if exist dirg.awk del dirg.awk
if exist tmp_dir.txt del tmp_dir.txt