How to find a file or folder in MS-DOS or Windows command line

Updated: 03/06/2020 by Computer Hope
Windows command line (DOS)

You can find any file on your computer using MS-DOS providing you know the name of the file or the program that created the file.

If you are unsure where the file may be on the computer, you must be at the root directory of the computer. Meaning, you must be at C:\> to get to this prompt, type the following command.


Once at the root directory or the directory you believe the file to be in, type any of the following commands.

If, for example, you knew that the file had bob somewhere in the file, you would type:

dir *bob*.* /s

The above example uses wildcards (the asterisks). Also, it uses the /s command switch to tell the dir command to search the current directory, and all its subdirectories.

If you cannot recall any of the names of the files but recall that they were created in Microsoft Excel you could, for example, type:

dir *.xls /s

In the above example, knowing Excel files often end with the .xls file extension, we use the wild character, telling the computer to search for any file ending with the .xls extension. If you don't know extension of your file, you can find a listing of the majority of extensions and the associated program on our MS-DOS extensions page.

Finally, once you have found the file, you must interpret the output of your search and be able to change directories to get to that file.

Below is an example of the results found when typing dir *bob*.* /s as mentioned in an earlier example.

Volume in drive C has no label
Volume Serial Number is 214B-1DE8
Directory of C:\Computer Hope\Info\Files
GENMSBOB HTM 2,592 12-19-96 7:01p genmsbob.htm
1 file(s) 2,592 bytes
Directory of C:\Games\chessmaster\Personalities
BOBO CMX 2,584 09-10-99 1:00a BoBo.CMX
1 file(s) 2,584 bytes
Directory of C:\Games\Quake 2\baseq2\players1\Morbo
MORBOB~1 PCX 25,798 01-09-98 4:24a morboBASE.pcx
1 file(s) 25,798 bytes
Directory of C:\Windows MYBOB TXT 4 11-19-00 3:23p mybob.txt
1 file(s) 4 bytes
Total files listed:
4 file(s) 30,978 bytes
1 dir(s) 29,500.53 MB free

As you can see in the above example, several files were found that contain bob. If you receive more than expected results, you may need to type /p after the command. Using /p displays the results one page at a time. If, for example, the file we were looking for was mybob.txt, looking above, we see that this file is in the C:\Windows directory.