Welcome, guest | Sign In | My Account | Store | Cart

Checking freespace of drives which active at execution batch moment.

Batch, 19 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
@echo off
  setlocal
    ::possible drive letters list
    set "map=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
    ::looking for drives with ready status
    for %%i in (%map%) do (
      dir %%i:\ 2>nul 1>nul && call:freespace %%i
    )
  endlocal
exit /b

::this function provides free space checking
:freespace
  for /f "tokens=3" %%i in ('dir /-c %1:\') do set "len=%%i"
  echo Drive   Freespace
  echo -----   ---------------------
  echo  %1:\     %len% (bytes)
  echo.
exit /b 0
Created by greg zakharov on Wed, 14 Nov 2012 (MIT)
Batch recipes (42)
greg zakharov's recipes (59)

Required Modules

  • (none specified)

Other Information and Tasks