Windows files search using command window
In Windows Command Prompt (CMD), you can use the dir
command to search for files in a specific directory. Additionally, you can use various parameters and operators to refine your search. Here are some common examples:
Basic File Search: To search for files in the current directory, simply open the Command Prompt and use the
dir
command:dir
Search in a Specific Directory: To search in a specific directory, specify the path after the
dir
command:dir C:\Path\To\Directory
Search for a Specific File: To search for a file with a specific name, use the
/b
parameter along with the filename:dir /b filename.txt
This will only display the filenames that match your search criteria.
Search for Files with a Specific Extension: To search for files with a specific file extension, use the
*.extension
wildcard:dir *.txt
This will list all files with a
.txt
extension.Search for Files in Subdirectories: To search for files in subdirectories as well, use the
/s
parameter:dir /s /b filename.txt
This will search for
filename.txt
in the current directory and all of its subdirectories.Search for Files by Date: You can search for files created or modified within a specific date range using the
/tc
(creation time) or/tw
(last write time) parameters. For example, to find files modified within the last 7 days:dir /s /b /tw /a-d /od /t:c-7
This command will search for files modified within the last 7 days, starting from the current directory and its subdirectories, and list them in order of creation time.
Search for Files by Size: To search for files of a specific size, you can use the
/s
and/b
parameters along with the>
or<
operators. For example, to find files larger than 1 MB:dir /s /b /a-d C:\Path\To\Directory\*.* | findstr /r /c:"^[0-9][0-9]*.*[1-9]..*MB"
This command searches for files larger than 1 MB in the specified directory and its subdirectories.
These are some common ways to search for files using the Windows Command Prompt (cmd.exe
). Adjust the parameters and operators to suit your specific search criteria.
Subscribe to my newsletter
Read articles from Arun Udayakumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by