How to Search for Files from the DOS Command Prompt - dummies

How to Search for Files from the DOS Command Prompt

By Dan Gookin

By opening a command prompt window, you can search for files that Windows truly doesn’t want you to know are there. It’s a little technical, but when you really, really need to find a file, the method described in the following steps does the job:

  1. From the Start menu, choose All Programs→Accessories→Command Prompt.

  2. Type CD and press Enter.

    That’s CD, a space, and then the backslash character. This command propels you to the root directory (folder) on the main hard drive.

  3. Type DIR and a space.

  4. Type the name of the file you’re looking for.

    For example, if you’re looking for the file secret.doc, type secret.doc. You can type upper- or lowercase letters.

    When you don’t know the full name, replace the part you don’t know with an asterisk (which is a wildcard). For example, you type secret* to search for all files beginning with the word secret.

    Don’t type any spaces. If you must type a space, use the ? (question mark) character instead.

  5. Type another space and then /S, a space, and /P.

    The complete command line to look for the file secret.doc appears like this:

    dir secret.doc /s /p

    The /s option directs a search of all folders on the hard drive; the /p option pauses the display after each screen of text. Double-check everything!

  6. Press the Enter key.

    The results display one screen at a time.

  7. Peruse the screen full of results.

  8. If you find a file that matches, you can open a Windows Explorer window to display the file’s folder.

    Press Win+E to open a Windows Explorer window.

    The pathname is found above the filename in the results. The pathname reads similar to this line:

    Directory of C:UsersDangDocumentsForgotten
  9. If the file isn’t found, press Enter to see the next screen (if necessary).

    The prompt reads Press any key to continue, but the Enter key is the “any key.” Repeat Steps 7 and 8 to review the results.

  10. Type the EXIT command to close the Command Prompt window when you’re done.

Yes, this method is not only technical — it’s tedious. But the DIR command does a thorough job of scouring the entire hard drive. Sometimes you may want to use it just to confirm that a file doesn’t exist.

See Video 212 to watch a search at the command prompt to find a lost file.