Find and Open Files Using Command Prompt in Windows

Find and open files using Command Prompt - Featured Image - Source: Pexels.

Beyond just typing text, the Windows Command Prompt can also be used to search for and open any files on your PC. Even if you can only recall part of the file name, the Command Prompt can find out where it is, and you can open it from within the cmd window. This approach is also handy in opening files with administrator privileges or directly launching any batch files or executables. The following guide shows how to open files using Command Prompt in Windows.

Open the Command Prompt in Windows

To get started, you need to launch the Windows Command Prompt. There are multiple ways to do this.

  • Search Box: type cmd in the Windows search box, then click on the Command Prompt icon to open the window. It’s always better to run the application in administrator mode.
  • Run Command: you can use the Run command Win + R and enter cmd, followed by Enter or click “OK.” To directly launch Command Prompt in Admin mode, use Ctrl + Shift + Enter.
Opening Terminal (Admin) using Power User menu, which is Win + X.

Also read: learn how to use Windows Defender from the Command Prompt. You can also permanently disable it if you want to.

How to Find Files Using Command Prompt in Windows

Once you launch the command prompt in administrator mode, the next step is to search for the files or folders you need. After that, if you want, you can open them from the console.

In Command Prompt, type dir "search term*" /s, but replace the words “search term” with the file name or a part of the name you remember. Here I’m trying to search for one of my picture folder albums titled “Eurotrip.”

Once you press Enter, it may look like nothing is happening. But after a few seconds, all the file paths mentioning the correct file or folder will be displayed. The correct file path can be easily identified by the size of the folder. Always check the actual File Explorer location to verify that the concerned files are available on your PC.

Open file locations in command prompt using dir command.

Here are the common terminologies used in searching for files using the command prompt:

  • dir is a command used to show files in the current directory but can also locate data elsewhere in the system.
  • The backslash (\) tells dir to search from the root directory of the current drive.
  • /s tells dir to search all sub-directories.
  • * is used by command-line apps as a wildcard. It indicates that the search will locate all file names that contain your search term.
  • Adding an asterisk at the end of the name, like business*, will find all the files with your search term at the beginning of the name.
  • If you use it at the beginning, your search will only include results with your text at the end. For example, *.jpg.
  • If you add an asterisk at each end of the search term, you will cover all the bases. No matter where your text is in the actual name of the file, that file will be listed with the results.

Tip: the Command Prompt in Windows lets you copy-paste anything you need. It can also help you run the Java programs from within the terminal emulator.

How to Open Files in Command Prompt

To do this, you need the location of the saved file. In this example, the file that we want to open is located in the Desktop folder.

Navigate to the required folder from This PC and right-click to navigate to Properties -> General -> Location. This will give you that folder’s path that is unique to your computer. In this example, the location is “C:\Files.”

Location path of a folder in File Explorer viewable using its Properties.

Using cd change your Command Prompt’s root directory to the desired folder.

Once you navigate to the innermost folder, open the file by typing the entire filename and .filetype. In the following example, the filename is “IMG_20150502_141629” and the filetype is a JPG file.

After typing the filename/filetype command, the correct file will be opened on your desktop window. Here as it is a picture file, it opens using the Photos app.

Opening JPG file in Command Prompt.

Note: you can open multiple files from the Command Prompt once you’ve opened the correct folder. Here we are opening a single image file in the command line window.

You can also use specific apps to open the file of your choice in Command Prompt. From the search menu, click Open file location to Identify the file location of the app you want to use to open a target file. Once it opens, go to Properties -> Shortcut -> Target and copy the app’s entire path.

Finally, use "App Location Path" "File Path" to open the file with the app of your choice in Command Prompt. Here we have opened an MP4 file using VLC from within the cmd window.

Opening a specific MP4 file in Command Prompt using VLC app

Also read: here is a list of safe websites for downloading Windows software.

How to Open Files Using Windows Terminal

The Windows Terminal is a modern extension of the Command Prompt. Opening files in Windows Terminal is no different than the above methods.

You need to change the default Terminal application to Command Prompt from a “+” menu if it’s set at something else, such as PowerShell or Azure Cloud Shell.

Open Command Prompt from within the Windows Terminal.

The Command Prompt will become the default Terminal application for opening files. After that, you can type cd to navigate to the desired folder. The instructions for opening the files are the same and have been covered above.

Tip: don’t like the boring look of the command line interface? Now you can use exciting new themes to brighten up your Windows Terminal and its programs.

Change Directories in Windows Command Prompt for Easy Access to Folder Paths

If your target file is located in a different drive, you won’t find it anywhere in a Windows folder path that is displayed on your screen. Therefore, you should change the Windows drive path to point it accurately.

Type cd.. which enables you to easily move one folder up. To go to a new drive, just type its name, and the Command Prompt will listen to the new drive. Here we have changed over from “C:/” to “Z:/.”

Moreover, using cd without the two dots allows you to set any new folder path as the default directory for systematic file navigation. To clear your entire screen and start over, type cls.

Changing from C to Z drive in Command Prompt using CD command.

FYI: Is Windows Security not opening for you? Read how the Command Prompt can help you here.

If you want to speed up other Windows tasks, you may also be interested in learning how to batch rename files and move multiple files with a batch file. To batch rename files, use the ren *.fileext1 *.fileext2 command. To avoid any errors, it’s a good idea to check the hard disk health in Windows beforehand.

Frequently Asked Questions

Can I open the Command Prompt window in a Windows folder?

You can open the Command Prompt window anywhere on a Windows PC. To do so in a Windows folder, navigate to the folder first, then right-click Windows terminal. The command prompt can be accessed as part of the Windows terminal.

How do I display the contents of a text file in Command Prompt?

To display the contents of a text file in the command prompt, enter the type command as shown below: type [<drive>:][<path of file>]<Name of File>

Can I edit text files in Windows Command Prompt?

You can edit, view, create, or modify any text document in Command Prompt.

  1. Use the type command followed by the file name.
  2. Copy-paste the text in the command window using copy con followed by the text name and location.
  3. Edit the document.

Image credit: Sora Shimazaki from Pexels. All screenshots by Sayak Boral

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sayak Boral
Sayak Boral - Staff Writer

Sayak Boral is a technology writer with over eleven years of experience working in different industries including semiconductors, IoT, enterprise IT, telecommunications OSS/BSS, and network security. He has been writing for MakeTechEasier on a wide range of technical topics including Windows, Android, Internet, Hardware Guides, Browsers, Software Tools, and Product Reviews.