Command Prompt Computer Programming tricks Tricks

How to Search Files With Command Prompt

There are many ways to search files in windows, but all are not effective and also you have to install different applications to search your files. Although there is a default search in windows 7 but it is bit slow. Then how to search files immediately and effectively.

What do you think ? About command prompt ? Yes you are right ! ! Almost all type of work can be done with command prompt then why not file searching. Just go through the following steps.
  • Copy and paste the following code in a notepad file and save it as .vbs extension.
set shell = CreateObject("WScript.Shell")
fileNam=Inputbox("Enter part of the file name you want to search","File Name")
If(fileNam <> "") then
dirName=Inputbox("In which drive you want to search ?"+vbcrlf+"Example: If you want to search in D drive then enter only D","Drive name")
msgbox "Searching the entire drive may take some seconds. Press OK continue.",,"Message" "Cmd.exe"
WScript.Sleep 3000
Shell.sendkeys "dir "+dirName+": /s /b | find "+Chr(34) + fileNam + Chr(34)+"{ENTER}"
End If
  • Make sure that you have saved the file in .vbs extension.
  • After you save, just double click on it to open. It will ask you for the file name to search and the drive name.
  • Just provide the required data and wait for a while.
  • A command prompt will open where some command will be automatically written and the search will start.
Search for files
  • It will hardly take 10 seconds to search your entire drive. It is the best and most effective trick. I love it.
Some more tricks with command prompt you may also like

Leave a Reply

Your email address will not be published. Required fields are marked *