Geez, now your name appeared as "Leonardo", with my email, like in the other post. However, I don't even have that name registered with my email! You do realize you ought to enter your OWN name and email (email not necessary) on the reply form, don't you? Anyway, let's just keep signing the posts on the end, ok?
The batch is mainly divided into two parts:
1. Make a list of all the .txt files to be checked and transform it so it works as a batch file to call a subroutine on the main batch script, passing each filename one by one;
2. On the subroutine, check if each of the filenames passed is 0-byte, and if so, display it.
I'll only explain the part you said you didn't understand. ZB.COM is an assembler program created, used and futher deleted by the batch script itself.
It will read input from STDIN. If there is any input, it returns errorlevel 0. Otherwise, if there's no input at all (that's what happens if STDIN is a 0-byte file), it returns errorlevel 1. There are other ways to check if a file is 0-byte or not. Here's the one I like most:
copy file.ext nul |FIND " 0 " > nul
if not errorlevel=1 echo file IS 0-byte!
if errorlevel=1 echo file IS NOT 0-byte!
That works because the COPY cmd, on DOS/Win9x, doesn't copy 0-byte files. It displays a message like " 0 File(s) copied" if you try it.
Note 1: The returned error message may change because of different OS languages, but the " 0 " part is fix, and so reliable.
Note 2: That method cannot be used on NT systems because the cmd's behavior is different.
So, why did I use ZB.COM, which takes the work of 4 lines to be created, some more work to delete it and makes the source so strange? That's because ASM programs are _very_ fast. Using it instead of that COPY method will make the process faster. That speed advantage on a single check isn't that important, and that's why I generally use the COPY method. However, if we're talking about several files to be checked, the time saved increases with each file that is checked using this faster method.
The commented source for that program follows:
nnnn:0100 MOV DX,0118 ;}
nnnn:0103 MOV CX,0001 ;}
nnnn:0106 MOV BX,0000 ;} read the 1st character from STDIN
nnnn:0109 MOV AH,3F ;}
nnnn:010B INT 21 ;}
nnnn:010D OR AX,AX ; did we read any data at all?
nnnn:010F JZ 0113 ; if not, skip next command
nnnn:0111 INT 20 ; 'default exit' (errorlevel=0)
nnnn:0113 MOV AX,4C01 ; set errorlevel to 1
nnnn:0116 INT 21 ; 'custom exit'
Those quoted terms aren't official, I just invented them to make the comments easier to understand.
I'm the author of that ASM program (wooow, what a program... Almost the complexity of an OS hehe...)
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br