Last Updated :
13 Mar, 2025
Ever lost a file on your computer and wished there was a quick way to find it without clicking through endless folders? Say hello to the Windows Command Prompt (CMD) a powerful little tool that can help you search for files fast. In this how-to blog, we will explore the steps to search for files using CMD simple commands, so you can find what you need in no time, no fancy software required.
So without further ado, let’s get into the process of finding files using CMD in Windows 10 and well in Windows 11.
How to Find Files Using CMD in Windows?
In this section we have mentioned some steps, so follow the few steps to get the lost file or file that you are looking for.
Step 1: Open CMD
To find your file first, open CMD or Windows Command Prompt, and to do this, click the Win+R button and type CMD, or you can click the Windows key and type CMD to open Windows Command Prompt.
Step 2: Use DIR Command
After successfully launching the Command Prompt, type the below command and press Enter to pull up a list of files and folders.
dir
Step 2: Use CD Folder Command
For moving down into a particular directory, use the below command followed by a folder name, until you reach the folder you want to search.
cd folder_name
Step 3: Use Aging DIR Command
Now type the dir command again but this time with your search term, follow dir with your search term in quotes with an asterisk term before closing the quotes (For example, type dir “Raveling*”) and press Enter. The command prompt will show you the file location along with the list of files name starting with a similar keyword.
The asterisk is what’s known as a wildcard and, in our example, it stands for anything that follows the word ‘highlands’, such as ‘raveling.doc’, ‘raveling.xls’ or My Business plans.txt’.
If you don’t know the exact location of your file in your hard drive, then instead of manually navigating through your directories, start searching from the very top level of your hard drive and include every sub-folder.
Step 4: Use Raveling Command
The top level of the drive is represented by a backslash and, to include subdirectories, you add a forward slash and ‘s’ to the end of the query as shown below:
dir “\Raveling*” /s
The above command is my all-time favorite because, with the help of this command, I don’t have to force my brain to remember the location of the files. This trick usually takes seconds to search the entire drive for the file.
You can also search for a particular file type by using a command dir \*.pdf /s and it will show you all files saved with the .pdf extension. You can try this for other files too (for example: .doxc, .png, .exe and more).
Note: The position asterisk symbol in the command matters a lot so type carefully and check once before executing the command.
How All The Commands Works?
Now you know enough to find any file on your entire hard drive within few seconds but if you are more curious to know how all these commands are working and what all these symbols stand for, then continue reading this post.
Let’s discuss each term one by one:
- dir command is for showing files on the current directory, but it can also show files from anywhere in the drive of the system.
- / tells dir to search from the top-level or root directory of the hard drive.
- /s is used for searching sub-directories.
- * asterisk is using before text (for example *.pdf) show all files ending with .pdf and * using at the end (for example raveling*) show you all file-names starting with that word.
Conclusion
Using the Command Prompt to search files in CMD is a valuable skill for anyone who frequently navigates through files and directories on a Windows system. By understanding the various commands available, you can easily find files with CMD and streamline your workflow. Whether you’re searching by name, location, or content, this method ensures that you can quickly locate the files you need with minimal effort.
If you are an advanced user of Windows, you might want to use the command line to find files on your system. You can use the command line to find files by date, content, size, and location, etc. In this article, I will show you how to use various methods and commands to find files using the command line in Windows 10/11.
Basic File Search Commands
One of the simplest ways to search for files using the command line is to use the dir and findstr commands. The dir command lists the files and folders in a directory, and you can use it with wildcards (*) to find file by name or extension from the Windows command line. For example, to use CMD to search for files with the extension TXT in the current directory, you can use the command:
dir *.txt
The Findstr command searches for a string of text in a file or files. You can use it with the /i option to ignore case sensitivity and with the /s option to search in all subdirectories. For example, to search for the word “hello” in all text files in the current directory and its subdirectories, you can use the command:
findstr /i /s "hello" *.txt
CMD Find File Name Containing a String
As mentioned, you can use the dir command to find a file name containing a specific string. For example, to find a file name containing the string “share” in the current directory and its subdirectories, you can type:
dir /s /b *share*
This will return a list of file names that match the pattern. The /s switch tells the command to search in all subdirectories, and the /b switch tells it to display only the bare file name.
You can also use wildcards to specify more complex patterns. For example, to find a file name that starts with “report” and with extension “.docx”, you can type:
dir /s /b report*.docx
Advanced File Search Commands
The find command searches for files that match certain criteria, such as name, size, date, and attributes. You can search words within files using the command prompt.
For example, to search for the word “hello” in all text files in the current directory, you can use the following command:
findstr /i /m "hello" *.txt
To search for all files larger than 1 MB in the C: drive, you can use the command:
forfiles /P C:\ /S /C "cmd /c if @fsize gtr 1048576 echo @path"
where Command for Executable Files
If you want to search for executable files, such as programs and applications, you can use the where command. It is mainly for locating executable files in a specified path or paths. You can use wildcards (*) with the where command to search for files with a specific name or extension. For example, to search for all executable files with the word “chrome” in their name in the C: drive, you can use the command:
where /r C:\ *chrome*.exe
Combine Dir and Find Commands
You can also use advanced filtering options with the dir command to search for files based on their attributes, such as size, date, and extension. You can use various switches with the dir command to filter your results. For example, to search for all readonly files in the current directory, you can use the command:
dir /a:r
To search for all files modified after January 1st, 2024 in the current directory, you can use the command:
dir /t:w /o:d | findstr /b "01/01/2024"
To search for all PDF files smaller than 100 KB in the current directory and its subdirectories, you can use the command:
dir /s *.pdf | findstr /v "<DIR>" | findstr /v "bytes" | findstr /r "[09][09][09] KB"
Windows CMD Find File Recursively
If you want to perform recursive searches using the dir command, you can use the /s switch. The /s switch searches for files in the current directory and all its subdirectories. For example, to search for all text files in the current directory and its subdirectories, you can use the command:
dir /s *.txt
Recursive searches are useful for locating files that are buried deep in your system’s folders.
You can also use the Where command to search recursively. For example, to list all files that start with “ffmp” in the c:\windows directory and its subdirectories, use the following command:
where /r c:\users ffmp*
PowerShell Commands for File Searches
PowerShell is a powerful command line tool that allows you to perform various tasks on your system. You can also use PowerShell commands to find files based on various criteria. For example, to search for all text files that contain the word “hello” in the current directory and its subdirectories, you can use the command:
Get-ChildItem -Path .\* -Include *.txt -Recurse | Select-String -Pattern "hello"
To search for all files larger than 1 MB in the C: drive, you can use the command:
Get-ChildItem -Recurse -Path C:\ | Where-Object {$_.Length gt 1MB}
To search for all PDF files created before January 1st 2024 in the current directory and its subdirectories, you can use the command:
Get-ChildItem -Path .\* -Include *.mp4 -Recurse | Where-Object { $_.CreationTime -lt '2024-01-01' }
Common CommandLine File Search Parameters
Here are some general tips for optimizing your command line file searches in Windows:
- Use wildcards (*) to search for files with a specific name or extension.
- Use the /s switch with the dir, find, and findstr commands to search in all subdirectories.
- Use the /r switch with the where command to search in a specified path or paths.
- Use the /a switch with the dir and find commands to filter files by attributes, such as hidden, readonly, system, etc.
- Use the /t switch with the dir command to filter files by date, such as creation, modification, or access.
- Use the /o switch with the dir command to sort files by name, size, date, or extension.
- Use PowerShell commands to perform more advanced file searches with various criteria.
Conclusion
In this article, I have shown you how to find files using the command line in Windows 11/10. Hopefully, you have learned to use advanced filtering and sorting options with these commands to get your results quickly.
In the Windows command prompt (CMD), we use the where
command to find files that match a specific search pattern.
where /r dir file_name
The where
command searches for files in the given directory and all subdirectories and returns the full path of each matching file to the standard output.
First, let’s look at a few examples to understand how CMD where
command works.
Examples
Search c:\
drive for the file file1.txt:
where /r c:\ file1.txt
Find the location of the chrome.exe
:
where /r c:\ chrome.exe
The following command finds all files that contain «report» anywhere in the filename in the c:\windows
and all subdirectories:
where /r c:\windows *report*
This command search c:\
drive to find filenames starting in «report»:
where /r c:\ report*
The following command search c:\
drive to find filenames ending in «report»:
where /r c:\ *report
In this example, every file in the c:\windows
(and all subdirectories) is searched for filenames ending in .txt
:
where /r c:\windows *.txt
Find all mp3 files in the d:\
drive:
where /r d:\ *mp3
The following command finds all mp3 files in the d:\ drive
and copies the output to the clipboard instead of printing it to the command prompt.
where /r d:\ *mp3 | clip
In this example, we save the output to a text file called output.txt:
where /r d:\ *mp3 > C:\output.txt
Add the /t
option to display the file size and last modification date and time:
where /t /r c:\windows *.log
Command Options
/r Dir | Specify the directory to search (the search is recursive). |
/f | If you use this option, the where command encloses filenames in quotation marks in the output. |
/t | Displays file size and last modification date. |
/? | Displays command options. |
If you know the exact name of the file you want to find, then specify the name without using any wildcards:
where /r c:\ file1.txt
The above command will search for file1.txt in C:
drive recursively.
If you don’t know the exact name, but only a part of it, then put an asterisk (*
) before and after the search term, as shown in the following example:
where /r c:\Docs *report*
In the above example, CMD where
command will return any files that have the string report anywhere in the filename.
To find files that start with a specific pattern, put an asterisk (*
) after the search term, as shown in the following example:
where /r c:\ report*
To find files that end with a specific pattern, put an asterisk before the search term:
where /r c:\ *report
In the following example, the where
command finds all files that have the .avi
extension on the C:
drive:
where /r c:\ *.avi
Remarks
- You can only use the
where
command to find files on CMD. It will not work on Windows PowerShell. - Run the
where /?
command to see a list of all the options.
The `find` command in CMD allows users to search for specific text strings within files, enabling efficient content discovery and text manipulation.
find "search_string" filename.txt
Understanding CMD and Its Environment
What is CMD?
CMD, or Command Prompt, is a command-line interpreter built into Windows operating systems. It allows users to execute various commands for file manipulation, configuration, and system control. By communicating directly with the system’s core functionalities, CMD offers a more direct and faster approach for users, especially programmers and system administrators.
Why Use CMD for File Searching?
Using CMD for file searching offers several advantages over graphical user interfaces:
- Efficiency: Commands can be executed quickly, often requiring less time than navigating through menus and options.
- Automation: CMD allows for the creation of scripts for repetitive search tasks, saving significant time and effort.
- Power: The ability to combine commands (like `find` with others) offers enhanced functionality that basic search tools lack.
Cmd Line List Files: A Quick Guide to File Management
The `find` Command
Overview of the `find` Command
The `find` command is a powerful tool in CMD used to search for specific text within files. By specifying text and a target file, users can pinpoint exact lines containing their search terms.
Syntax:
find [options] "search_text" [filename]
Key Options Available
Case Sensitivity
- /C: This option counts the number of lines containing the specified text. It can be helpful when trying to gauge the frequency of occurrences in a file.
- /I: This option makes your search case-insensitive, meaning it will match «Error», «error», and «ERROR» alike. This is particularly useful for variable capitalization in file contents.
File Specifying
You can specify filenames using wildcards. The asterisk (*) represents any number of characters, while the question mark (?) stands for a single character. This flexibility allows a user to search through multiple files at once.
Master Cmd Copy Files with Ease and Efficiency
Practical Examples of Using `find`
Basic Search
To search for a specific term in a single log file, you can use the command as follows:
find "error" logfile.txt
In this example, the command looks for the term «error» within `logfile.txt`. The output will display the lines that contain this word, making it easy to identify issues quickly.
Searching Multiple Files
You can use wildcards to search for terms across multiple files. For example, to search for the term «success» in all `.txt` files in the current directory:
find "success" *.txt
This command retrieves instances of «success» from any text files, streamlining the search process across several files.
Using `find` with Other Commands
Piping Output
CMD allows you to combine commands to filter results. For instance, if you want to find a specific filename in a directory, you can pipe the output of `dir` to `find`:
dir | find "filename"
In this command, `dir` lists all files and folders in the current directory, while `find` filters that list based on your specified term, making it highly efficient.
Cmd Count Files: Master File Counting in Cmd
Advanced Searching Techniques
Using `findstr` for Regular Expressions
Overview of `findstr`
`findstr` is an enhanced command that offers more powerful text searching capabilities, including support for regular expressions, which allows for more complex search patterns.
Syntax:
findstr [options] "search_strings" [filename]
Key Features and Options
- /S: This option searches for the specified string in the current directory and all subdirectories. This is particularly useful for large projects with multiple nested directories.
- /R: With this option, users can utilize regular expressions for more advanced searches. This capability opens doors for searching patterns rather than fixed strings.
Advanced Example with `findstr`
Suppose you want to retrieve lines that contain either «error» or «warning» in all `.log` files throughout a directory structure:
findstr /S /R "error warning" *.log
This example showcases the command’s power and flexibility in filtering multiple terms across various files.
Error Handling & Common Issues
Handling Spaces in File Names
When dealing with file paths that contain spaces, it’s crucial to enclose file names within quotes. Failing to do so can lead to errors:
find "search_term" "C:\Path To\My File.txt"
Using quotes ensures that the command interprets the entire path correctly.
No Results Issues
If your command returns no results, consider the following troubleshooting tips:
- Verify the Search Term: Ensure that the term you are searching for indeed exists in the files.
- Check File Path: Confirm that you are specifying the correct file path and filename. Typos can easily lead to missed finds.
Effortless File Transfers: Cmd Move Files Made Easy
Conclusion
Navigating CMD can significantly enhance the efficiency of file searches. Mastering commands like `find` and its counterpart `findstr` not only boosts productivity but also empowers you to leverage the full capabilities of CMD. I encourage you to practice these commands in your Command Prompt and discover how they can simplify your workflow!
Mastering Cmd Disklist: Your Quick Guide to Disk Management
Resources for Further Learning
For those eager to dive deeper into CMD and enhance their command-line skills, consider exploring the official CMD documentation. Engage with online forums and communities where CMD enthusiasts share tips and tricks, and explore other useful commands that complement file searching.