Find and Open Files using Windows Command Prompt - Windows Basics

Latest

Tuesday, July 12, 2022

Find and Open Files using Windows Command Prompt

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

How to open Command Prompt

Before searching and opening files with Command Prompt, you must be able to open Command Prompt. There are several ways to open Command Prompt that you can use:

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

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

Way 3. The next way is to use the Power User Menu. Press Windows Keys + X then click Command Prompt (Admin) or press A to open Command Prompt as admin

Way 4. you can command open command prompt to Cortana to open Command Prompt

How to search files with Command Prompt

In the Command Prompt window that has just opened, enter dir "\*search term* /s, replace search term with the file name you want to find.In the example below, Quantrimang tries to search for files/folders named as funvideo.

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

Now we will explain a bit about the components in the above statement:

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

Change the drive to locate files more accurately

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

First, type cd..then press Enter to tell the Commad Prompt that 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.

Now you can search for the file you need by executing the dir "\search term*" /s command again. Notice how the * sign is used to search more efficiently. If you enter it incorrectly, you will get a "no label" error message like the example below. My advice is to always use two * at the beginning and end of the search keyword.

Open files with Command Prompt on Windows 10

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

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

Enter the file name with the full extension inside double quotes ".." then press Enter. The file will be opened with the default software. You can open more files if they are in the same folder as the original file.

After the job is done, if you need to open other files, you can use the cd.. command with the path to switch to the new directory.

Good luck

No comments:

Post a Comment