check size of file in a batch file

wraughed
wraughed used Ask the Experts™
on
I would like to be able to check the size of a file and if the size is zero then delete it.  
this is using windows 2000 in a batch file.

Thanks

wraughed
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
You would need a third-party tool to do this--there isn't a standard Windows 2000 batch file command which will do the job, AFAIK.
Commented:
Hello,


for %%? in (filename.ext) do if %%~z? == 0 goto zerobyte
echo File is not zerobyte!
goto eof
:zerobyte
echo File is zerobyte!
:eof

That would work for NT systems only. For Win9x/DOS, this would do it:

FC filename.ext nul |FIND "FC: " > nul
if not errorlevel=1 goto zerobyte
echo File is not zerobyte!
goto eof
:zerobyte
echo File is zerobyte!
:eof

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial