Find and Open Files and Folders Using Command Prompt in Windows 10
The Command Prompt offers a lot of cool tricks and lets you access a lot of Windows features, including many that are not accessible from within the GUI. Here, we will show you how to find and open files using the Command Prompt. While you can do it using the Windows File Explorer, the methods detailed below will help you if you forget the full filename or don’t remember where you stored it on your computer. Note: I’m using Windows 10 for this demo, but the same methods will apply in Windows 7/ 8/ 8.1 and older. Also, you can use the methods below to find and open any type of folder or file in Windows 10 command prompt (CMD), including text, video, music, and more.
Find a File or Folder Using Command Prompt
Open Windows Command Prompt in Admin mode by searching for ‘cmd’ in the Windows Search Bar and selecting ‘Run as administrator’.
Now type in dir “*file name*” /s to search for the target file on your C:\ drive. Make sure to replace “file name” with the actual name of the file or folder you’re trying to find. For this demo, I’m trying to find a file called ‘demo1.jpg’.
You’ll get multiple results even if there’s only a single file with that name. However, you can easily identify the correct path by its size.
By default, the aforementioned command will search the C:\ drive. If you have multiple drives on your PC, you will need to specify the target drive. For example, to search the D:\ drive, you should type ind: and press Enter.
Now just use the dir “*file name*” /s command described earlier to find your target file or folder. Do note that you can also use just one asterisk (instead of two), either at the start or at the end of the filename. Putting the wildcard at the end will find all the files with your search term at the beginning of the name, while putting it at the start will list all files with your search term at the end. I’m putting the asterisk at both ends to find all files that include the search text, whether at the start, end or somewhere in between.
Open Files Using Command Prompt
Once you know the precise path of a file (image, text, video, music) or folder, you can easily open that using the Command Prompt in Windows 10. Here’s how you do it:
Method 1: Open Files in Command Prompt Via the Folder Route
Firstly, specify the directory and folder of the file you’re trying to open. In my case, the target file lies in a folder called ‘Demo Folder’ at the root of the D: drive. So, we’ll first get to the root of the D: drive. For that, type in d:and press Enter as detailed in the earlier segment. You can drop this step if you’re trying to open a file in drive C:.
Now access the target folder with the following command: cd demo folder/
Finally, type-in “demo2.jpg”(including quotes) and press Enter.
Windows will open the file using the default app associated with that file type.
Method 2: Open Files in Command Prompt Directly
Meanwhile, you can also open files directly from the command prompt if you know the full file path. Here’s how you do it:
Say you want to open a file at “C:\Users<username>\Desktop\Stuff\Img\Jan 2021\28 Jan\CMD\demo1.jpg”. For that, open Command Prompt and ensure that you point it at the right drive first. Then, just type-in the full path (including quotes) and press Enter.
Specify an App to Open a File Using Command Prompt
In both the aforementioned cases, the file will be opened using the default app associated with that file type. You can, however, specify any app on your PC to open that file. Say, your JPG files open with Adobe Photoshop by default, but you can open it with Paint (or any other compatible app) if you want. Here’s how you do it:
To open the same ‘demo1.jpg’ file using Paint, we will have to direct the OS towards the installation folder for ‘mspaint.exe’ alongside the full path of the file itself. For that, we’ll use the following syntax: “%windir%\system32\mspaint.exe” “C:\Users\Kundu\Desktop\Stuff\Img\Jan 2021\28 Jan\CMD\demo1.jpg”(including quotes).
The command above will open the ‘demo1.jpg’ file with MS Paint instead of the default photo viewer app on your PC. Do note that the file paths may vary from one computer to another.
Get Things Done Using Command Line Tools in Windows 10
Now that you know how to find and open files and folders using the Command Prompt in Windows 10, go ahead, give it a shot, and let us know why you’re looking to use the Command Prompt to find and open files on your PC. In case you like working with command-line tools in Windows but the more feature-rich PowerShell is your weapon of choice, check out our tutorial on how to personalize Windows PowerShell on your PC. You can also check out everything about the Windows Terminal and how to install and customize it on your computer.