1.

Solve : Zero Byte Files?

Answer»

Hi,

I have done some DOS batch programming in the past, but I have run into a SITUATION where I could use some help.

How do tell if a FILE has 0 (zero) bytes. I have a script that goes to an FTP site to bring in a file. It creates a file EVEN if there is nothing there, hense a file with zero bytes.

I want to be able to test for this and NOT copy it to a directory that other software is monitoring. The software process it, but generates errors. The users don't LIKE errors.

I can do it in a *nix script, but I am at a loss to do it in DOS.

I seem to remember a batch file comparing an existing zero byte file to the new file and if it matched, then it was emtpy.

I can't find the reference and I can't find anything in my DOS manuals.

HELP.

Thanks to all.edi_guy!

Is this what you want?

set file=filename.txt
for %%a in ("%file%") do set size=%%za
if "%size%" NEQ "0" echo.DO THE COPY


or

set file=filename.txt
dir "%file%"|find /i " 0 %file%">NUL&&echo.DO THE COPY


I would prefer the first one.
Check also http://dostips.cmdtips.com/DtCodeSnippets.php

Hope this helps



Discussion

No Comment Found