Open file from command line windows

Find and Open Files using Windows Command Prompt

Finding and opening the files through windows explorer is simple but it takes some time. There is a faster way to achieve the same using the command prompt. Working through the command prompt is the quickest way to get things done. Through the command prompt, you can find things quickly and allows you to open the files right there.

Search a file in Windows Terminal

Type cmd in the search bar of your Windows 10 computer. From the results, click on the command prompt to open it. Type the following line in command prompt window:

Replace the search term with the file name that you want to search.

I will describe a little what the terms in the command actually means.

  • Dir — It is used to list the list of files and subfolders contained in a folder.
  • \ — It is used to tell dir to search from the root directory of the current drive.
  • * — It’s a wildcard character. if used before a name (e.g *data), will search for text that ends with that specific name data. If used after a name(e.g data*), will search the text starting with the name data.
  • /s — It is used to tell dir to search from all sub-directories

For instance to search a file name “data set”, I will enter”

It will list file names starting with name screenshot3 along with its directory.

Open a file from Windows Terminal

After you find the file you want to open, you can launch it without navigating through windows file explorer.

In a command prompt window, type cd followed by the path of the file that you wish to open. After the path matches with the one in the search result. Enter the file name of the file and press Enter. It will launch the file instantly.

By following the above method, you can easily search and open a file using command prompt as it is a quick way of accessing any file as compared to windows file explorer.

Find and Open Files Using Command Prompt in Windows 10

Do you ever drive yourself crazy looking for all the files you need for a project? Have you saved them in unknown places on your computer? Can you only remember part of the name you gave the file? If any of these apply to you, using the command prompt instead of Windows Explorer may help you quickly find the files you need and allow you to open them directly from that location.

We have to mention, though, that it’s a waste of time using the Command prompt to open simple, trivial files. However, this method is something you should definitely look at when dealing with multiple files and assorted file types in random folders.

Opening Command Prompt

To search for the files you want, first launch Command Prompt. There are several ways to do this.

  • Type cmd in the Windows search box, then click on the icon to open the window. It’s preferred to run the command prompt as an administrator.
Читайте также:  Настройка веб камеры для mac os

  • Use the Run window. A fast way to launch this window is to press the Win + R keys on your keyboard. Then, type cmd or cmd.exe and press Enter or click OK.

  • Use Cortana if it works for you properly: as soon as you see the Cortana is “listening” text, say “open command prompt,” and it will open up.

Search for your files

In the command prompt, type dir «\search term*» /s , but replace the words “search term” with text you want to find by using the file name. In the following screen, we are trying to search for a folder/file named “movies.”

The correct file path can be easily identified by the size of the folder. Once you have typed in the command, press Enter, and the search begins. It may look like nothing is happening for a second or two, though. But soon all the file paths mentioning the correct file or folder will be identified and named.

What do all the terms in the command mean?

  • dir is a command used to show files in the current directory but which can also locate data anywhere in the system.
  • The backslash tells dir to search from the root directory of the current drive.
  • /s tells dir to search all subdirectories.
  • Finally, * is used by command-line apps as a wildcard. It indicates that the search will locate all file names that contain your search term.
  • Putting 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 put it at the beginning, then your search will include only results with your text at the end. For example, *.jpg .
  • If you put 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.

Change Command Prompt Directories for Precise File Location

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 learn to change the drive path as shown below.

First, type cd.. , which will enable you to easily move one folder up. To go to D drive, just type d: , and the command prompt will now listen to the new drive.

Within the destination drive, you can search for the correct file once again using the dir «\search term*» /s command discussed in the previous section. 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 as shown below. If you type correctly, you will easily identify the folder path and the correct file name.

If the folder path is very long, you may want to copy-paste the entire thing. We have a detailed tutorial on how to cut-copy-paste in the Windows 10 command prompt. But the method is simple enough: use Ctrl + A to select the entire command prompt screen, then just release the mouse or trackpad click. This would make any part of the command screen selectable for a copy-paste action as shown below.

Читайте также:  Как сделать свои анимированные обои для windows 10

Open your Files in Windows 10 Command Prompt

Once you find the file you want to open, you can open it from this screen using its default program, without locating it in your file explorer.

First, 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 in the previous section. Once the correct directory menu has been opened, you can open any files there. Here it’s a folder, where I saved my personal collection of rented movies.

Enter the file name inside the quotation marks «..» as shown here. Press Enter and the file will open using its default application. Here it’s Movies and TV programs, which is set as my default application for .mp4 files.

The file, a Mel Gibson-led movie called “Get the Gringo,” opens from the command prompt.

You can open multiple files from the command prompt once you’ve opened the correct folder. Here we open another file called “Erin Brockovich.mp4” in the same folder.

The file, a Julia Roberts-led movie called “Erin Brockovich,” opens from the command prompt using the default app.

Once you’re done, you may want to move back to another folder in the command prompt. For this, use cd.. followed by a new drive name as shown below. Navigating your computer’s files using the command prompt is very similar to just doing it in a regular way from your File explorer.

Wrapping Up

If you are looking for all your files concerning one topic or just trying to find the one that is hiding among all the folders in your computer, try using the command prompt. It may make it more efficient for you.

Amazingly, the command prompt is way 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. The reason for this is that the GUI always consumes more memory and slows down the processes.

Related:

Sayak Boral is a technology writer with over ten 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.

How to Open a File/Folder in Command Prompt (CMD) Windows 10 [MiniTool News]

By Alisa | Follow | Last Updated December 31, 2020

Summary :

Wonder how to open a file cmd or how to open a folder in Command Prompt on Windows 10? This tutorial provides a step-by-step guide. Also, if you can’t find some files or folders in Windows 10, or some files are unexpectedly lost in your Windows 10 computer, MiniTool free data recovery software for Windows 10/8/7 can help you easily recover lost files.

You can also open files from Command Prompt. Wonder how to open a file or folder in Command Prompt on Windows 10? Check the step-by-step guide in this tutorial.

How to Open a File CMD Windows 10 in 2 Steps

Step 1 – Open Command Prompt

You can press Windows + R keys on the keyboard to open Windows Run dialog. Then type cmd in the Run box. If you want to run Command Prompt as Administrator, you need to press Ctrl + Shift + Enter keys at the same time.

Читайте также:  Windows media player как добавить кодек

Alternatively, you can also click Start or Search box in Windows 10, and type cmd or command prompt. Right-click the Command Prompt app in the list and choose Run as administrator.

Step 2 – Open Files from Command Prompt

Normally you have two ways to open a file using cmd. One is to move the folder that the file is in, the other is to open the files directly in Command Prompt.

Method 1. How to open a file with cmd by moving to the folder firstly

  • You can use the cd command to move to the exact folder the file lies in. For instance, cd C:\Users\mini\Desktop.
  • After you are in the correct folder path, you can type the name of the file with its extension, e.g. “travel.png”, and hit Enter button to open it.

Windows 10 repair, recovery, reboot, reinstall, restore solutions. Learn how to create Windows 10 repair disk, recovery disk/USB drive/system image to repair Windows 10 OS issues.

Method 2. How to open a file using cmd directly

You can also choose to open files from Command Prompt on Windows 10 directly, instead of going to the folder path. You can input the full path, file name and its file extension to open the target file, e.g. “C:\Users\mini\Desktop\travel.png”.

You can also freely specify an app to open the file. You need to type the whole path of the app ahead of the path of the file. For example, C:\Users\mini\”%windir%\system32\mspaint.exe” “C:\Users\mini\Desktop\travel.png”.

How to Open a Folder in Command Prompt Windows 10

You can also open a folder from Command Prompt with the command line below.

After you enter into Command Prompt window by following the operation above, you can open a folder in File Explorer in Command Prompt. The command line can be like this, start %windir%\explorer.exe “C:\Users\mini\Desktop”.

Tip: Need to mention that you need to enclose the path of a file or folder in double quotation marks, since some folder or files names have spaces in them.

To Recover Unexpectedly Lost Files or Folders in Windows 10

Sometimes you may suffer unexpected data loss in Windows 10 due to various reasons, e.g. system crash, Blue Screen error (e.g. Bad Pool Caller BSOD error), power outage, malware/virus infection, hard drive failure, etc. To easily recover lost data for free, you can choose the best free data recovery software to realize it.

MiniTool Power Data Recovery, a 100% clean and free data recovery software for Windows 10/8/7, enables you to easily recover mistakenly deleted files or lost files from computer local drive, external hard drive, SSD drive, USB drive (pen drive data recovery), SD card, and more.

Easy 3 steps to fast recover my files/data for free with best free file recovery software. 23 FAQs and solutions for how to recover my files and lost data are included.

  • Facebook
  • Twitter
  • Linkedin
  • Reddit

ABOUT THE AUTHOR

Position: Columnist

Alisa is a professional English editor with 4-year experience. She loves writing and focuses on sharing detailed solutions and thoughts for computer problems, data recovery & backup, digital gadgets, tech news, etc. Through her articles, users can always easily get related problems solved and find what they want. In spare time, she likes basketball, badminton, tennis, cycling, running, and singing. She is very funny and energetic in life, and always brings friends lots of laughs.

Оцените статью