Search for Files from the MS-DOS Command Prompt

With all the advancements in computing and the fancy and functional Graphic User Interface available, MS-DOS is no longer used by the majority of computer users. MS-DOS as an Operating system is not used but a Command Shell known as Windows Command Line is still used. However, many persons would be shocked to see MS-DOS used on their computer, they may never know that it even exists. Searching for files using MS-DOS allows you to search the whole hard drive for files. This would be a thorough search of the hard drive for the file that you are looking for. Searching with MS-DOS is a way to be sure that a file exists or does not exist on the computer since this will be a thorough search of the computer. Searching with the command prompt is also a very fast way to search the whole computer or just a specific file or drive.

1] Opening MS-DOS

To open MS-DOS press Start then type Command or CMD and you will see Command Prompt come up in the search. Click the Command prompt icon to open it or go to Open. You may also click Search and type Command or CMD and you can then open the Command Prompt from there.

You will see a black window with white words open. This is the command prompt interface that you will use. You can try it out by typing dir and then press enter.

Dir will give a list of the content of the current directory.  You will see the directory name and path for example C:\Users\my pc. Below that you will see a table list of the directories with time and date. Read: Pin PowerShell or Command Prompt with Admin rights Shortcut to Start Menu

2] Keyword Searching

Using command prompt is a little technical and you need to remember the commands to use. Command prompt is a great way to stretch your brain though. When you have opened command prompt type CD / then press enter. CD / will take you to the root directory, change the directory or just show the current directory.

To start searching for a file type Dir and then a space then type the name of the file that you are looking for.  If you type Dir and then press enter, you will be shown the directories of the current drive that you are on. In this case, it is drive C. When you type Dir then space and the name of the file, you are saying that you are searching the directory of the current drive for the file specified. An example of a search would be Greenery, and greenery may be the name of a text file. To search for Greenery you would type dir greenery.txt /s /p then press Enter. The /s option directs a search of all folders on the hard drive; the /p option pauses the display after each screen of text. If the p is not placed in the search syntax, the search result would be one continuous result in the case where there are a lot of search results. The p tells the computer to break up the results. To move on to another page of results just press Enter.

This is how you would type it in the command prompt, and how it would look.

This is what would be displayed on the screen when you press enter and the search is being done.

This is what is displayed if the file is not found.

This is what is displayed when the search is successful.

You have the option of searching for the file using the full name if you know it. If you are not sure of the full file name, you can fill in the missing part with an asterisk (this is the wildcard). For example, if you are searching for a file that you think is named Greenery or Green something, it may be a text file created in word pad. If you are not sure of the full name, you can search for Green*. The search will look for all files that begin with the word Green.

This is what would be typed in command prompt dir green* /s /p and the way it would be displayed in the command prompt. The search using the wild card may return a lot of results, if you do not use the p in the search syntax, the screen will scroll automatically with results, and you will have to keep scrolling back to be able to see the previous results. The search using the wild card can also be used if you remember the last part of the file name but not the first. You would type the asterisk and then the part that you remember. You would type dir  *ery /s /p and then press enter. The command prompt would look like this.

4] Search Using the File Extension

Another way to search is by using the file type/extension. Since you know that the file is a text file you can search for .txt extension. This is good for cases where you forgot the file name but you know the file extension. You would type dir *.txt /s /p into the command prompt then press enter.  The \ means start from the root and /means subdirectories. That means you are telling the command prompt to search the root directory and all subdirectories.

5] Accessing the File

After finding the file using the command prompt, you may want to access it. To access the file you simply open an explorer window then copy and paste the path of the file in the address bar at the top. You can also find the file by pasting the path from command prompt into the search field in Windows. The path to the file is usually above the file that is found. So if you are looking for greenery, when you find it you will see the path to the file just above it.

The file found and the path to it.

6] Troubleshoot Searching With Command Prompt

You may be searching for a file and you are getting a file not found or finding an incorrect file. Look closely at the spelling of the file name. if the name is incorrect if will not find it or it may return a file that has the same name as the incorrect spelling. Note that if you are not using the wild card (* asterisk) after the file name, you will have to put the file extension after the name. for example, if you type dir greenery /s /p, you will get file not found. You would either write dir greenery.txt /s /p or dir greenery* /s /p

7] Some MS-DOS Commands

cd – Change directory or display current directory path.cls  –  Clear the window.dir  – Display list of contents of current directory.help – Display list of commands or help about a command.notepad  – Run the Windows Notepad text editor.type – Displays the contents of a text file.exit – exits the command promptexplorer – Opens Windows Explorer

Read:

How do I find a file using Command Prompt?

You would first have to open the command prompt by going to search and typing CDM or command then open it. When the command prompt screen opens type dir filename.extension /s /p. you may also search for the file by typing wild card character * at the part of the file name that you forget. If you are looking for a file called book and you forget the last letters type dir bo* /s /p. if you forget the first part type dir ok.txt /s /p. that is if it is a text file, if you forget the file extension you could write dir book /s /p.

How do I open a file that I found in Command Prompt?

When you have searched for a file in command prompt and you have found it then the next step may be to open it. You open an explorer window then copy and paste the path of the file in the address bar at the top then press Enter. You can also find the file by pasting the path from command prompt into the search field in Windows.