Skip to content

Instantly share code, notes, and snippets.

@EONRaider
Created July 13, 2026 19:27
Show Gist options
  • Select an option

  • Save EONRaider/4bb11e69903d3f1e7c2111c6961eba2f to your computer and use it in GitHub Desktop.

Select an option

Save EONRaider/4bb11e69903d3f1e7c2111c6961eba2f to your computer and use it in GitHub Desktop.
Basic Windows Shell File Search Commands

To find files within a Windows command shell (CMD), you can use several built-in commands depending on the complexity of your search.

Common File Search Commands

  • dir command: This is the most basic way to list files in the current directory.

    • To search recursively through all subdirectories for a specific file name, use: dir /s <filename>
      • Example: dir /s config.php
  • where command: This is excellent for locating the path of executable files or specific files within the system's PATH environment variable.

    • Syntax: where /r <directory> <filename>
      • The /r flag tells it to search recursively starting from the specified directory.
  • findstr command: If you are looking for files that contain specific text content rather than just a file name, you can use findstr.

    • Syntax: findstr /s /i "search_string" *.*
      • /s: Searches the current directory and all subdirectories.
      • /i: Makes the search case-insensitive.
      • *.*: Specifies that you want to search through all file types.

Pro-Tips for Efficient Searching

  • Permissions: Always be aware of your current user privileges. If you are searching in system directories (like C:\Windows or C:\Users), you may receive "Access Denied" errors if you do not have sufficient permissions.

  • Wildcards: You can use the asterisk * as a wildcard. For example, dir /s *.txt will list every text file found in the current folder and all subfolders.

  • Output Redirection: If the search returns a massive list of results, you can output them to a text file for easier reading using the > operator: dir /s > results.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment