- 1 year ago
Search folder name in whole disk/subfolders via FINDSTR by one line cmd?
To search for a folder name in the entire disk, including subfolders, you can use the dir
command along with the findstr
command in one line of CMD. Here's an example:
cmddir /s /b "C:\*" | findstr /i "foldername"
In this command:
dir /s /b "C:\*"
lists all files and folders recursively (/s
) in the root directory (C:\
) and subdirectories, displaying only the file or folder names (/b
).findstr /i "foldername"
searches for the specified text ("foldername") case-insensitively (/i
) within the output of thedir
command.
Replace "foldername" with the name of the folder you want to search for. Make sure to enclose the folder name in double quotes if it contains spaces or special characters.
This command will search the entire disk starting from the root directory (C:\
) and display the paths of any folders that match the specified name. The search is case-insensitive (/i
), so it will match both uppercase and lowercase names.
Note that searching the entire disk can take a significant amount of time, depending on the size and contents of your disk. Additionally, some folders may require elevated privileges to access, so running the command with administrative privileges may be necessary to search certain system folders.
Feel free to adjust the command as needed to suit your specific requirements.