How to Open and Access Files From the Windows Command Prompt

Key Takeaways

  • The Windows Command Prompt provides a text-based interface to interact with your computer’s file system and run commands.
  • You can navigate directories, open files, copy/move/delete files, and perform various file operations using Command Prompt commands.
  • Mastering Command Prompt file management can greatly improve your productivity, especially when dealing with large numbers of files or automating tasks.

The Windows Command Prompt, also known as the command-line interface (CLI) or cmd.exe, is a powerful tool that allows you to perform various tasks on your computer using text-based commands. One of the most common uses of the Command Prompt is to open and access files on your system. In this comprehensive guide, we’ll explore different methods to open and access files from the Command Prompt, along with practical examples and tips.

Opening Files with the Command Prompt

There are several ways to open files from the Command Prompt, depending on the type of file and your desired action. Here are some common methods:

1. Opening Text Files

To open a text file (e.g., .txt, .log, .bat) in the default text editor (usually Notepad), you can use the following command:

notepad file_name.txt

Replace file_name.txt with the actual name and extension of the text file you want to open.

2. Opening Image Files

To open an image file (e.g., .jpg, .png, .bmp) in the default image viewer, use the following command:

start file_name.jpg

Again, replace file_name.jpg with the actual name and extension of the image file.

3. Opening Other File Types

For other file types, such as documents, spreadsheets, or executables, you can use the start command followed by the file name and extension. Windows will automatically open the file with the associated program.

start file_name.docx
start file_name.xlsx
start file_name.exe

Navigating Directories and Accessing Files

Before you can open a file from the Command Prompt, you need to navigate to the directory where the file is located. Here are some useful commands for navigating directories and accessing files:

1. Changing Directories

To change the current working directory, use the cd (change directory) command followed by the path of the desired directory.

cd C:\Users\Username\Documents

You can also use relative paths to navigate directories:

  • cd .. to move up one level
  • cd \ to go to the root directory

2. Listing Files and Directories

To list the contents of the current directory, use the dir command.


This will display all files and subdirectories in the current directory. You can also use the /b switch to list only the file and directory names without additional information.

dir /b

3. Copying, Moving, and Deleting Files

The Command Prompt also allows you to perform various file operations, such as copying, moving, and deleting files. Here are some common commands:

  • Copying files: Use the copy command followed by the source file and destination path.
copy file_name.txt C:\Destination\Folder
  • Moving files: Use the move command followed by the source file and destination path.
move file_name.txt C:\Destination\Folder
  • Deleting files: Use the del command followed by the file name(s) or wildcard patterns.
del file_name.txt
del *.txt

Advanced Command Prompt Techniques

As you become more proficient with the Command Prompt, you can explore advanced techniques to enhance your file management capabilities:

1. Using Wildcards

Wildcards allow you to perform operations on multiple files at once, based on specific patterns. The most common wildcards are:

  • * (asterisk): Matches any sequence of characters
  • ? (question mark): Matches a single character

For example, to delete all text files in the current directory, you can use:

del *.txt

2. Combining Commands

You can combine multiple commands in a single line using the && operator. This can be useful for executing a series of commands in a specific order.

cd C:\Folder && dir && notepad file.txt

This command will first change the directory to C:\Folder, then list the contents of that directory, and finally open the file.txt file in Notepad.

3. Using Command Prompt Scripts

If you find yourself executing the same set of commands repeatedly, you can create a batch script (.bat or .cmd file) to automate the process. Batch scripts are text files containing a series of Command Prompt commands that can be executed with a single command.

Save this script as backup_files.bat, and then you can run it from the Command Prompt by typing backup_files.bat.


The Windows Command Prompt is a powerful tool for managing files and directories on your computer. By mastering the various commands and techniques covered in this guide, you can significantly improve your productivity and efficiency when working with files. Whether you’re a developer, system administrator, or power user, the Command Prompt is an invaluable resource that can streamline your workflow and automate repetitive tasks.