Using the great answer from @Nifle, but including your specifics try:
% find /Volumes/WD -type d -name *[TEST]* | while read a; do if [ ! -f $a/Data.log ]; then echo $a; fi; done
Breaking this one-liner down:
find /Volumes/WD -type d -name *[TEST]*: Walks the file tree from /Volumes/WD into your external HD looking for directories (-type d) which have [TEST] somewhere in their name (-name *[TEST]*).
The output from the find command is piped (by |) into the bash while loop which pulls matching directories out one at a time storing them in a variable a.
Within the loop:
- The
if statement checks that the file Data.log isn't in the directory being considered. In the if statement, $a is expanded so that $a/Data.log is a path like /Volumes/WD/<dir1>/<dir2>/Data.log. To get the test you're interested in ! and -f are used so that only cases where a file with that name doesn't exist will evaluate to TRUE (! is NOT, and -f indicates a file rather than any other type of filesystem entry like directories or links).
- Finally, if we find a matching directory, it is printed by
echo $a where $a is replaced as above by the directory name piped in from find.
I know I'm rehashing a previous answer, but I hope this clears up what is going on in the great one-liner put forward by @Nifle and gets your problem solved.