# Checking file sizes in DOS



## Tigers! (Apr 3, 2006)

Since my last question was solved so well :wave: here I am again

Want to check if a file's size (Anotset.tmp) is zero. If it is delete it and leave program. If not continue on. Anotset.tmp contains a list of Q20_* files in the current directory.



```
rem *** Testing for presence of Q20 files with A attribute not set ***
dir /b /a:-a | findstr /c:"Q20_" > Anotset.tmp

rem *** If such Q20 files not present delete temp file and exit ***
for /f %%A in ("Anotset.tmp") do (
   if %%~zA equ 0 del Anotset.tmp
   echo no Q20 files present
   goto END
)
```
The first piece of code 'dir /b /a:-a | findstr /c:"Q20_" > Anotset.tmp' collects any available Q20_* files

At present even if the file Anotset.tmp has a size > 0 (i.e. some Q20_* files have been found) the program goes into the routine above, prints the message "no Q20 files present", deletes Anotset.tmp and exits. It should not enter this routine if Q20_* files are present.

I am wondering if the problem is the '()' with the do command. I am not at all sure whether you can have '()' with the do or if command.

Or do I need to break this routine up further with gotos?


----------

