Sunday, January 12, 2025
HomeProgrammingWindows - How to do a Simple File Search in cmd

Windows – How to do a Simple File Search in cmd

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

See also  Difference Between .js and .mjs Files

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:

See also  Static Keyword in Java

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).

See also  Object Class in Java

/b: Displays the output in bare format (just the file names and paths).

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x