Getting sub folders by name with windows cmd
Within a batch-script, I would like to list all subfolders with a given name. I can do it in general but have problems, when there is subfolder direclty in the folder where I am searching. I am doing this on Windows 7 cmd.
Code I use to list all subfolders with name bin:
dir /s /q /b /A:D bin
If I have a folder structure like this: ".\a\bin .\b\bin .\c\bin" it works fine.
if I have structure like this: ".\bin .\a\bin .\b\bin .\c\bin" it only lists the content of ".\bin".
Does anybody know any workarounds?
dir /s /b /A:D *|findstr /ri "[\\]bin$"