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?
- How to Open Command Prompt in Windows
- How to Search for Files Using Command Prompt in Windows
- How to Change Directories in Windows Command Prompt for Easy Access to Folder Paths
- How to Open Files in Command Prompt by File Name and File Type
- How to Search for the Correct Files With Command Prompt
- How to Open Files in Windows Command Prompt
- How to Open Files Using Windows Terminal
- Frequently Asked Questions
Also read: How to Use Windows Defender from the Command Prompt
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.
Also read: 8 Ways to Customize Windows Terminal
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.
- Use the Run window. A fast way to launch
cmd
is to press the Win + R keys, Then typecmd
orcmd.exe
and press Enter or click “OK.” To directly launch Command Prompt in Admin mode, press Ctrl + Shift + Enter.
- 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.
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.
- 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.
Also read: Windows Security Not Opening in Windows? Here are 6 Fixes
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:
- 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.”
- 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
tellsdir
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.
Also read: 15 Safe Websites for Downloading Windows Software
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.
- Type
cd..
which enables you to easily move one folder up. - To go to D drive, just type
d:
, and the Command Prompt will listen to the new drive.
- Using
cd
without the two dots allows you to set a new folder path as the default directory for systematic file navigation. - Using
cls
clears the entire screen and returns you to the previous folder path.
Also read: How to Permanently Disable Windows Defender
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.
- 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.
- Using
cd
change your Command Prompt’s root directory to the desired folder.
- 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.
- After typing the filename/filetype command, the correct file will be launched on your desktop window.
Also read: 6 Ways to Check Hard Disk Health in Windows
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.
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.
Also read: Do I Need Antivirus Software If I Have Windows Defender?
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.
- 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. - 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.
- 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.
- 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.
- Use
"App Location Path" "File Path"
to open the file with the app of your choice in Command Prompt.
Navigating your computer’s files using the Command Prompt is very similar to doing the same with file explorer.
Also read: How to Hide Updates Using PowerShell in Windows
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.
- 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.
- The Command Prompt will become the default Terminal application for opening files.
- In the following Windows Terminal example, we are typing
cd..
to navigate to theC:\Windows
folder. - we are opening the Registry Editor file in that location by simply typing
regedit
.
Also read: 9 JavaScript/Node.js One-Liners You Should Know
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.
- Use the
type
command followed by the file name. - Copy-paste the text in the command window using
copy con
followed by the text name and location. - 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
Our latest tutorials delivered straight to your inbox