Page 1 of 1

how to check the file size of a file

Posted: 31 Mar 2011 09:09
by eshwar
Hi Team,

I am a new bee to batch script!!
i want to check the size of a file which is in a location (its a dynamic file so it should be like %.zip file)

please give me some suggestions..

thanks in advance!

-Eshwar

Re: how to check the file size of a file

Posted: 31 Mar 2011 09:28
by cactusman252
This should show you the file size of every file in that directory in bytes. And the total size of the directory.
I think this is what you meant.


@echo off
Set /a Total=0
Set /a Size=0

echo =======================================

for /f "tokens=*" %%I in ('dir /b') do (
Call :TotalSize %%~zI
echo %%I %%~zI
)
Echo .
Echo Total %Total%
Echo .
echo =======================================
pause
goto :EOF

:TotalSize
set Size=%1
Set /a Total=%Total%+%Size%
goto :EOF