how to check the file size of a file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
eshwar
Posts: 1
Joined: 31 Mar 2011 09:04

how to check the file size of a file

#1 Post by eshwar » 31 Mar 2011 09:09

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

cactusman252
Posts: 10
Joined: 08 Mar 2011 08:54

Re: how to check the file size of a file

#2 Post by cactusman252 » 31 Mar 2011 09:28

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

Post Reply