Reputation: 31733
Consider the following directory structure
- Temp\
- Temp\DirA\
- Temp\DirA\Content\
- Temp\DirA\Content\file.txt
- Temp\DirB\
- Temp\DirB\Content\
- Temp\DirB\Content\file.txt
Now I want to list all text files inside the content directories in a single line statement. I would expect something like this to work:
dir Temp\*\Content\*.txt
but it does not (it gives an syntax error). Even forfiles returns an empty result. Is there a convenient way to achive this?
Please note: My real world command will contain multiple wildcards. I don't wanto to combine foreach directory with foreach file.
Upvotes: 2
Views: 59
Reputation: 73586
Use recursive dir /s
and filter the output by \Content\
:
dir /s /b Temp\*.txt Temp\*.log | find "\Content\"
And in case you don't need to list the files in Content\other_folder\
use a regexp:
dir /s /b Temp\*.txt Temp\*.log | findstr /r "\\Content\\[^\\]*$"
Upvotes: 3