Find and Open Files Using Command Prompt in Windows

Open Files Command Prompt Featured

The Windows Command Prompt can be used to search for and open any files on your PC. This is very useful if you saved your file to an unknown folder and only remember a part of the file name. However, there’s no benefit nor harm in applying this method to files with a known location. But for those files that are difficult to locate, this article shows how to find and open files in Command Prompt in Windows 11 and Windows 10.

What Is the Benefit of Using the Command Prompt to Open Files?

Whether you are looking for all your files concerning one topic or just trying to find the one hiding among all the folders on your computer, try using the Command Prompt. It may make it more efficient for you.

On top of that, using the Command Prompt is much faster and more responsive than opening the files from the File Explorer. This is true for video files, Windows Photos, Word documents, and heavy-duty games, as the GUI always consumes more memory and slows down the processes.

How to Open Command Prompt in Windows

To search for the files in Windows, you first need to launch Command Prompt. There are several ways to do this:

  • Through Search Box. Type cmd in the Windows search box, then click on the icon to open the window. It’s wise to always operate the command line as an administrator.
Windows Command Prompt File Open Run As Administrator Search Menu
  • Use the Run window. A fast way to launch cmd is to press the Win + R keys, Then type cmd or cmd.exe and press Enter or click “OK.” To directly launch Command Prompt in Admin mode, press Ctrl + Shift + Enter.
Windows Command Prompt File Cmd Open From Run Menu
  • Use Win + X : Another fast way to launch cmd is to use the Win + X combination, also known as the Power User menu. Among the various options in Windows 11, you will find Windows Terminal and Windows Terminal (Admin), which are the latest terminal emulators to run both Command Prompt and PowerShell from one window.
Windows Command Prompt File Open Win X Open Windows Terminal Admin

Note: in certain older Windows 10 versions, when you launch the Win + X hotkey combination, you may instead see the Command Prompt and Command Prompt (Admin) options.

Windows Command Prompt File Open Command Prompt Admin Windows10
  • Use Cortana: try Cortana if it works for you. As soon as you see ther Cortana is “listening” to text, say “open command prompt,” and it will open up.
Windows Command Prompt File Open Start Command Prompt From Cortana

How to Search for Files Using Command Prompt in Windows

Searching for files and folders using the command line is very easy. Follow the instructions below:

  1. 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. In the following screen, we are trying to search for a folder/file titled “Stock videos.”
Windows Open Files Command Prompt Search Dir Search Term
  1. Once you press Enter, it may look like nothing is happening for a second or two, but soon all the file paths mentioning the correct file or folder will be identified and named. The correct file path can be easily identified by the size of the folder.

What do all the terms mean in the command line search request?

  • 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 in the results.

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

If your target file is located in D: drive, you won’t find it anywhere in the Windows folder from the C: drive. Therefore, you should change the Windows drive path in the command line as shown below.

  1. Type cd.. which enables you to easily move one folder up.
  2. To go to D drive, just type d:, and the Command Prompt will listen to the new drive.
Windows Open Files Command Prompt Cd Change Directory One Step At A Time
  1. Using cd without the two dots allows you to set a new folder path as the default directory for systematic file navigation.
  2. Using cls clears the entire screen and returns you to the previous folder path.
Windows Open Files Command Prompt Cls Command

How to Open Files in Command Prompt by File Name and File Type

We will explore a simple demonstration of how to open a file clearly visible to you as system administrator. To do this, you would need the location of the saved file. In this example, the file that we want to open is located in the Desktop folder.

  1. Navigate to the required folder from “This PC” and right-click to select “Properties.” This will give you that folder’s path that is unique to your computer.
Windows Command Prompt Desktop Properties
  1. Using cd change your Command Prompt’s root directory to the desired folder.
Windows Command Prompt Change Folder To Desktp
  1. Once you’re set to the right folder, open the file by typing the entire filename and .filetype. In the following example, the filename is “Marathon,” and the filetype is an .MP4 video.
  1. After typing the filename/filetype command, the correct file will be launched on your desktop window.
Windows Command Prompt File Open File Name Filetype Desired Folder

How to Search for the Correct Files With Command Prompt

Within the destination drive, you can search for the correct file once again using the dir "search term*" /s command discussed earlier. Do take care to use the * wildcard, both at the beginning and end of the search term for a comprehensive search – especially if that folder has hundreds of files. It’s pretty common to make mistakes in the wildcards and backslash, which returns a “no label” error. If you type correctly, you will identify the folder path and the correct file name.

Windows Open Files Command Prompt Dir Open Specific File

If the folder path is very long, you can copy-paste the entire thing. Windows 11 has built-in support for copy-pasting in the command line.

For Windows 10, check out this detailed tutorial on how to cut-copy-paste in the Command Prompt. The method is simple enough: use Ctrl + A to select the entire Command Prompt screen, then, release the mouse or trackpad click. This will make any part of the command screen selectable for a copy-paste action.

Windows Command Prompt Fileopen Copypasting Command Prompt

How to Open Files in Windows Command Prompt

Once you find the file you want to open, you can open it from the Command Prompt screen using its default program without having to locate it in your file explorer.

  1. Change the directory to the immediate folder where the file is located. This can be done using cd followed by the entire folder path to the correct file. It’s common to make mistakes, so it’s better to copy-paste the entire folder path as discussed earlier. Once the correct directory menu has been opened, you can open any files.
  2. Enter the file name inside the quotation marks ".." Press Enter and the file will open using its default application.

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

Windows Command Prompt Fileopen Open Directly Filepath
  1. You can use specific apps to open the file of your choice in Command Prompt. For example, video files can be opened using VLC Player. Identify the file location of the app you want to use to open the desired file.
Windows Command Prompt Fileopen App Open File Location
  1. The file location of the app is accessible in “Properties.” Copying the path is useful, as it will be pasted directly to the Windows command line.
Windows Command Prompt Fileopen App Path Defined
  1. Use "App Location Path" "File Path" to open the file with the app of your choice in Command Prompt.
Windows Command Prompt Fileopen Open File Using Specific App

Navigating your computer’s files using the Command Prompt is very similar to doing the same with file explorer.

How to Open Files Using Windows Terminal

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

  1. 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.
Windows Command Prompt Open Files Open Cmd In Windows Terminal
  1. The Command Prompt will become the default Terminal application for opening files.
  2. In the following Windows Terminal example, we are typing cd.. to navigate to the C:\Windows folder.
  3. we are opening the Registry Editor file in that location by simply typing regedit.
Windows Command Prompt Open Files Regedit C Windows

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 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.

Can I batch rename files in Command Prompt?

If you want to speed up other Windows tasks, you may be interested in learning how to batch rename files and move multiple files with a batch file. To batch rename the files, use the ren *.fileext1 *.fileext2 command.

Image credit: claudiodivizia by 123RF. All screenshots by Sayak Boral

Sayak Boral
Sayak Boral

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.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox