How can I check and compare a folder size to a known size and echo pass or fail - Batch Script?

77 Views Asked by At

I've started with this script for use on a Windows 98 machine.

It does what I need it to do for a specific file but I need to have this same function results with the size of the folder and it's sub-folders combined. I'm sure coding is completely different for a folder than a file but I need help.

@echo off
setlocal
set file="test.cmd"
set maxbytesize=16305780

FOR /F "usebackq" %%A IN ('%file%') DO set size=%%~zA

if %size% EQU %maxbytesize% (
    echo.Folder is the right size - PASS
) ELSE (
    echo.Folder is wrong size - FAIL
)
0

There are 0 best solutions below