Windows command prompt find specific folder name in sub folders

command linewindowswindows-search

Say I have a folder tree such as:

C:\Users\Test\My Documents
C:\Users\Test2
C:\Users\Test3\My Documents

What command can I run to search through C:\Users to check which sub folders have a My Documents folder?

So for the above it would come back with:

C:\Users\Test\My Documents
C:\Users\Test3\My Documents

But not

C:\Users\Test2

Also, if I wanted to script renaming any sub folders that are found to be called My Documents and rename these to just Documents, how could I achieve this?

Best Answer

DIR /AD /B "My Documents" /S

for listing the folders

Related Question