This should work
@echo off for /d /r %%f in (*) do ( if not exist %%f\test.txt ( echo %%f >>C:\folders.txt ) )
This will lead to the output of all folders that do not contain the test.txt file to the C:\folders.txt , just tweak / adjust your needs.
source share