DOS batch script to list folders that have a specific file in them

Posted by Lee on Stack Overflow See other posts from Stack Overflow or by Lee
Published on 2010-04-23T17:09:58Z Indexed on 2010/04/23 17:13 UTC
Read the original article Hit count: 270

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about directory

Related posts about for