How to find and open files using Command Prompt

How to find and open files using Command Prompt

Sometimes finding files on Windows 10 becomes difficult for users who are accustomed to using File Explorer when they only remember a little information of the file. In such cases, using the Command Prompt will help you easily find the file you want. Moreover, the Command Prompt also allows you to open files directly from the folder containing them.

How to find and open files using Command Prompt

  • How to open Command Prompt
  • How to search for files using Command Prompt
  • Change the drive to position the file more accurately
  • Open the file with Command Prompt in Windows 10

How to open Command Prompt

Before searching and opening a file with the Command Prompt, you must open the Command Prompt first. There are several ways to open the Command Prompt that you can use:

  • Press the Windows button to open the Start menu then type cmd , click the first search result to open Command Prompt . You can also right-click then choose Run as administrator to open the Command Prompt as administrator

  • Another faster method to open the Command Prompt is to use Run . Press Windows + R to open Run then type cmd or cmd.exe and press Enter or click OK

  • The next way is to use the Power User Menu. Press Windows + X then click on Command Prompt (Admin) or press A to open Command Prompt as admin
  • Finally, you can issue command ” open command prompt ” for Cortana to open Command Prompt

How to search for files using Command Prompt

In the Command Prompt window that opens, enter dir "*search term * /s , replace the search term with the name of the file you want to find. In the example below, let’s try to search for files / folders named “funvideo”.

After you press Enter for 1 to 2 seconds, the search results will be displayed. All files / folers related to the funvideo will be listed.

Now let’s explain a bit about the elements in the above statement:

  • dir is a command used to display files in the current directory but can also access the data anywhere on your computer.
  • The command prompt searches for the root drive of the current device
  • /s prompt the dir to search all sub-drives
  • Finally, the * is used by command line applications as a wildcard. It signals that the search command will find all the filenames containing your search term
  • Add a * at the end of the name, just as business* will search all files with the search keyword at the beginning of the name
  • If you put an * at the top, your search will only include results with the keyword in the back. For example *.jpg .
  • If you put a * in both the beginning and the end of the search keyword, you will cover all cases. Whether the keyword you enter is the actual file name or not, the file will still be listed in the search results.

Change the drive to position the file more accurately

If you save the file in drive D: you will not be able to find it if you do a search on drive C :. Therefore, you need to change directory according to the steps below.

First, type cd.. then press Enter to let Commad Prompt know you need to change the drive. Next, to change to drive D you need to type d: and press Enter . From now on, all commands will be executed on drive D.

This command on our machine cannot execute because there is no D drive

Now you can find the file you are looking for by executing the command dir "search term*" /s . Please pay attention to how to use the * sign to search more effectively. If entered incorrectly, you will get a “no label” error message like the example below. Make sure to always use two * at the beginning and end of a search keyword.

Open the file with Command Prompt on Windows 10

After finding the file, you can immediately open it with the Command Prompt with the default software.

First, you need to change the path to the directory where the file is located. You can do this by using the cd command with the path to the file directory. The best way to avoid errors is to copy the directory path listed in the search results.

Enter the filename with the full extension inside the quotation marks ".." then press Enter. The file will be opened with the default software. You can open additional files if they are in the same folder as the original file.

When you’re done, if you need to open other files you can use cd.. along with the path to switch to the new directory.

I wish you success and invite you to refer to other great tips on Quantum:

4