Finding files from the MS-DOS command line
With all the advances in computing and a trendy and functional graphical user interface, MS-DOS is no longer used by most computer users. MS-DOS is no longer used as an operating system, but a command shell known as the Windows Command Prompt is still in use. However, many people would be shocked to see MS-DOS in use on their computer, they may never know it even exists.
Searching for files with MS-DOS allows you to search for files across your entire hard drive. This will be a thorough search on your hard drive for the file you are looking for. Searching with MS-DOS is a way to make sure a file exists or doesn’t exist on a computer, as it will be a thorough search of the computer. Searching using the command line is also a very fast way to search your entire computer, or just a specific file or drive.
- Opening MS-DOS
- Keyword Search
- Pattern search
- Search by file extension
- File access
- Troubleshooting searches using the command line
- Some MS-DOS Commands
Open MS-DOS press start then type Command or CMD and you will see Command Prompt appear in the search. Click command prompt open it or go to open. You can also click Search and type Command or CMD then you can open Command Prompt from there.
You will see an open black window with white words. This is the command line interface you will be using. You can try this by typing dir and then pressing enter.
Dir will list the contents of the current directory. You will see the directory name and path, such as C:Usersmy pc. Below you will see a table listing directories with time and date.
Using the command line is a bit technical and you need to remember which commands to use. However, the command line is a great way to stretch your brain. When did you open command prompt enter 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 followed by a space, then enter the name of the file you are looking for. If you type Dir and then press enter, you will be shown the directories of the current drive you are on. In this case, it’s drive C.
When you type Dir followed by a space followed by a file name, you are saying that you are looking for the specified file in the current drive’s directory. An example search would be Greenery, and greenery could be the name of a text file.
To find Greenery, enter dir greenery.txt /s /p and press Enter. /s directs the search to all folders on the hard drive; /p pauses display after each screen of text. If p is not placed in the search syntax, the search result will be one continuous result in case of a large number of search results. P tells the computer to split the results. To move to another page of results, just press Enter.
Here is how you enter it on the command line and what it will look like.
Here is what will be displayed on the screen when clicked enter and the search is on.
This is what is displayed if the file is not found.
This is what is displayed on a successful search.
You have the option to search for a file by its full name if you know it. If you are unsure of the full filename, you can fill in the missing part with an asterisk (this is a wildcard). For example, if you are looking for a file that you think is called Greenery or Green something, it might be a text file created with a text notepad. If you are unsure of the full name, you can search for Green*. The search will look for all files that start with the word Green.
This is what will be entered on the command line dir green* /s /p and how it will be displayed on the command line.
A wildcard search can return a lot of results, if you don’t use p in the search syntax, the screen will automatically scroll with the results and you will have to keep scrolling back to see previous results.
Wildcard search can also be used if you remember the last part of the filename but not the first. You would type an asterisk and then the part you remember. You must type dir *ery /s /p and then press enter.
The command line will look like this.
4]Search using file extension
Another way to search is by using the file type/extension. Since you know the file is text, you can search for .txt. This is useful in cases where you forgot the file name but know its extension. You must type dir *.txt /s /p into the command prompt and then press enter. start from root and / means subdirectories. This means that you are telling the command line to search the root directory and all subdirectories.
Once you find the file using the command line, you can access it. To access a file, you simply open an explorer window, then copy and paste the file’s path into the address bar at the top. You can also find the file by pasting the path from the command line into the search box on Windows. The file path is usually above the found file. So, if you’re looking for greenery, when you find it, you’ll see the file path right above it.
Found file and path to it.
6]Troubleshoot Searching with Command Prompt
Perhaps you are looking for a file and you get a file that is not found, or you find the wrong file. Look closely at the spelling of the file name. if the name is incorrect, if it does not find it, or may return a file that has the same name as the misspelling.
Note that if you don’t use a wildcard (* asterisk) after the filename, you will have to specify the file extension after the filename. for example, if you type dir greenery /s /p you will get file not found. You should write dir greenery.txt /s /p or dir greenery* /s /p.
7]Some MS-DOS Commands
- cd Change directory or display the path to the current directory.
- cls – clear the window.
- dir – List the contents of the current directory.
- help – Show a list of commands or help about the command.
- Notepad – Launches the Windows Notepad text editor.
- type – displays the contents of a text file.
- exit – exit from the command line
- File Explorer – opens Windows Explorer
How to find a file using the command line?
First you need to open a command prompt by searching and typing CDM or command, then open it. When the command prompt screen opens, type dir filename.extension /s /p. you can also search for a file by typing a wildcard * in the part of the filename you forgot. If you are looking for a file named book and you forgot the last letters, type dir bo* /s /p. if you forgot the first part, type dir *ok.txt /s /p. if it is a text file, if you forget the file extension you can write dir book* /s /p.
How can I open a file that I found on the command line?
When you’ve searched for a file on the command line and found it, the next step might be to open it. You open an explorer window, then copy and paste the file path into the address bar at the top, then press Enter. You can also find the file by pasting the path from the command line into the search box on Windows.
I hope you enjoyed this article and you can learn more about how to search for files from the MS-DOS command line. If I missed something, please share your opinion in the comments section below. subscribe to useguide.net newsletter for some cool tricks and tips.