To perform a simple file search in Windows Command Prompt (cmd), you can use the dir command. Here’s how:
Syntax
cmd Copy code
dir [path] [filename] [/options]
Examples
1. Search for a File in the Current Directory
If you know the file name (e.g., example.txt):
cmd Copy code
dir example.txt /s
2. Search for a File in a Specific Directory
Specify the directory and file name:
cmd Copy code
dir C:\Users\YourUsername\Documents\example.txt /s
3. Search for Files by Extension
For example, to search for all .txt files in a directory and its subdirectories:
cmd Copy code
dir *.txt /s
4. Search for Files in the Entire Drive
To search for all .png files in the C: drive:
cmd Copy code
dir C:\*.png /s
5. Filter Results for Readability
You can combine options like /p (pause after each screen) and /o (order by name):
cmd Copy code
dir *.txt /s /p /o
Explanation of Common Options:
/s: Searches all subdirectories.
/p: Pauses output after each screen.
/o: Sorts the output (e.g., /o:n sorts by name, /o:d sorts by date).
/b: Displays the output in bare format (just the file names and paths).