How to Open Files and Folders in CMD on Windows

Command Prompt is a gem of a tool on Windows. It lets you perform several actions with single lines of code. Did you know you can also open files and folders in CMD and even delete them? In this article, we want to show you how to do it!

Open File in CMD 1

Opening files using CMD may come in handy when you don’t want to spend a long time navigating to the destination. Further, this may also help you open hidden files on your Windows PC.

Additionally, when you’re dealing with specific system issues or errors, using Command Prompt to access and modify files can help fix problems that might not be easily solvable through File Explorer.

Let’s begin with opening a file using CMD on Windows.

How to Open a File Using Command Prompt on Windows

Here’s how you can easily open Command Prompt on your PC and use it to access a file. However, you must know the file’s path on your PC before proceeding with the steps.

Step 1: Open the Command Prompt app from the start menu.

Open Command Prompt 17

Step 2: Now, type cd, followed by file path, and hit enter.

cd “folder_path”

To copy the path of any folder, right-click on the folder and click on ‘Copy as Path’. Our folder path here is “C:\Users\rsupr\OneDrive\Desktop\Sample Folder”.

Note: Ensure to enter all the paths within double quotes.

Enter Folder Path

Step 3: Next, enter the file name and its extension in double quotes.

The name of the file we are using is “Sample Image” and its extension is “.png”.

Step 4: Hit the enter key, and the file will open.

See more:  Sindel Combos in Mortal Kombat 1

Open File in CMD

Also Read: Create a folder or file from Windows Command Prompt

How to Open a Folder Using Command Prompt

Here’s how you can open a folder using CMD on Windows.

Step 1: Open the Command Prompt app from the start menu.

Open Command Prompt 17

Step 2: Now, type cd and paste the path of the folder you want to open. Once done, hit enter.

cd “folder_path”

To copy the path of any folder, right-click on the folder and click on ‘Copy as Path’. Our folder path here is “C:\Users\rsupr\OneDrive\Desktop\Sample Folder”.

Note: Ensure to enter all the paths within double quotes.

Enter Folder Path

Step 3: Next, enter the following command to open the folder on your PC. Hit the enter key.

start .

Open Folder

How to Delete Files Using CMD on Windows

You can also delete files using simple commands on CMD in Windows. However, this permanently deletes the file, so proceed with caution. Here’s how you can do it.

1. Delete Individual File

Step 1: Open the Command Prompt app from the start menu.

Open Command Prompt 17

Step 2: Now, type cd, followed by the file’s path you want to delete. Hit the enter key.

cd “folder_path”

To copy the path of any folder, right-click on the folder and click on ‘Copy as Path’. Our folder path here is “C:\Users\rsupr\OneDrive\Desktop\Sample Folder”.

Note: Ensure to enter all the paths within double quotes.

Enter Folder Path 1

Step 3: Type del followed by the name of the file you want to delete. Hit the enter key.

Ensure to enter the filename and its extension within double quotes. The name and extension of the file we are using are “Sample Image” and “.png”.

Delete File in CMD

2. Delete All Files Within a Folder

You can also permanently delete a folder’s contents at once using a single command. Here’s how:

Step 1: Open the Command Prompt app from the start menu.

Open Command Prompt 17

Step 2: Now, type del and paste the path of the folder whose contents you want to delete. Hit the enter key.

See more:  How to Stop Google Translate From Popping Up in Apps

del “folder_path”

To copy the path of any folder, right-click on the folder and click on ‘Copy as Path’. Our folder path here is “C:\Users\rsupr\OneDrive\Desktop\Sample Folder”.

Delete Folder

Step 3: Type ‘Y’ to confirm your action or ‘N’ to abort the process and hit the enter key.

Type Y or N

Bonus: Copy or Move Files to Different Locations Using CMD

You can also copy or move files from one destination to another on your Windows PC within CMD. Here’s how:

Step 1: Open Command Prompt from the start menu.

Open Command Prompt 17

Step 2: Now, type cd and paste the path of the file you want to copy or move. Hit the enter key.

cd “folder_path”

To copy the path of any folder, right-click on the folder and click on ‘Copy as Path’. Our folder path here is “C:\Users\rsupr\OneDrive\Desktop\Sample Folder”.

Enter Folder Path 2

  • To copy a file to a different location, type copy and the source file’s name and the destination folder’s path. Once done, press enter.

copy “filename.extension” “destination_path”

Our file is “Sample Image.png” and the destination path is “C:\Users\rsupr\OneDrive\Documents”.

Note: Ensure to enter all the paths, the filename, and its extension within double quotes.

File Copied

Note: If a file of the same name exists in the destination folder, you will receive a prompt whether you want to overwrite the file or abort the process. Type Y (yes) to overwrite or N (no) to abort, and hit enter.

Copy Prompt

  • To move a file to a different location, type move, followed by the source file’s name and the destination folder’s path. Now, hit enter.

move “filename.extension” “destination_path”

Our file is “Sample Image.png” and the destination path is “C:\Users\rsupr\OneDrive\Documents”.

Note: Ensure to enter all the paths, the filename, and its extension within double quotes

Move File Using CMD 1

Note: If a file of the same name exists in the destination folder, you will receive a prompt whether you want to overwrite the file or abort the process. Type Y (yes) to overwrite or N (no) to abort and hit enter key.

Move Prompt

That is everything you need to know on how to open files and folders using CMD on Windows. If you have any further questions, move to the following section.

See more:  How to Enable Angle Snapping Mouse

FAQs on Opening Files Using Command Prompt

1. Do I need to open Command Prompt as an administrator to open files?

No, you do not need to open Command Prompt as an administrator to open, delete, move/copy files on your Windows PC.

2. Why is CMD showing errors when I am trying to open a file?

Ensure you use the ‘cd’ command before entering a directory. Further, ensure that all paths and filenames are enclosed within double quotes. Make sure to include the extension of the filename as well.

3. How to open a folder using CMD?

All you need to do is to type ‘cd’ and enter the path of the folder in double quotes. This will open the folder to CMD, and you can type the file names present in the folder to open it.

4. How do I find the full name of a file along with its extension?

Right-click on the filename, select properties, and select the General tab. You can see the file’s full name and its extension in the ‘Type of File’ section.

Take Advantage of Windows Terminal

Command Prompt is a Swiss army knife with countless tools to control Windows. It might look intimidating to work with commands at first, but once you learn how to use them – it can save you tremendous effort and time!

Categories: How to
Source: thpttranhungdao.edu.vn/en/

Rate this post

Leave a Comment