Windows batch file to list folders that have a specific file in them
- by Lee
I'm trying to create a file that has a list of directories that have a specific file name in them.
Let's say I'm trying to find directories that have a file named *.joe in them. I initially tried just a simple dir /ad *.joe > dir_list.txt , but it searches the directory names for *.joe, so no go.
Then I concluded that a for loop was probably my best bet. I started with
for /d /r %a in ('dir *.joe /b') do @echo %a >> dir_list.txt
and it looked like it wasn't executing the dir command. I added the "usebackq", but that seems to only work for the /F command extension.
Ideas?