Search code examples
windowscommand-linecmd

How to do a simple file search in cmd


I want to quickly search for a file given its name or part of its name, from the windows command line (not power shell). This is similar to opening explorer and using the search box at the top.

Note: dir can search based on a string template but it will not search in the subdirectories.

Note2: findstr can be used to search for a token inside files and has a recursivity flag; it's funny that a more complex find can be easily discovered ...


Solution

  • dir /s *foo* searches in current folder and sub folders.

    It finds directories as well as files.

    where /s means(documentation):

    /s Lists every occurrence of the specified file name within the specified directory and all subdirectories.