How to Rename Files & Folders – Using the Windows Command Line (CMD, Ren, Batch)

What We'll Learn:


This short guide is all about renaming files and folders from the windows command prompt (cmd).

  • We are going to learn, how to navigate to the location of our files and folders.
  • How we can rename them using the ren command.
  • And how to change the extensions of our files, from our current as well as different directories.

Lets get started!

Preparation - Navigating to where our file/folder is located.

Before we begin learning how to rename our files and folders we must first learn how to change the location of our command line into to the location in which our items are located.

By default the command prompt is located at a folder within your users directory that’s named after your computers username (C:\Users\MyPC). From here we can use the “Dir” command to view every file and folder in this directory.


The name of every file and folder as well some information about each one of them will appear.

For example, lets assume that the file or folder we want to rename is located in our desktop. Between all the files we can see our desktop folder, to navigate there we need to use the “CD” command.

Simply type “CD” followed by the name of the folder you want to navigate into within quotes.

Cd "Desktop"

Your current directory will immediately change.

Incase you navigated to a different directory by mistake navigate back to your parent directory by typing “CD” followed by two dots.

Cd ..

You should now be able to use the “Dir” and “CD” commands to navigate to the appropriate location from the command line.

With all that said lets now rename our files and folders.

Renaming Files – Using CMD (Ren):

To rename our files and folders we need to use the Ren command. As you can probably guess, ren stands for rename. Renaming a single file is quite easy.

Simply type the ren command followed by the name of the file you want to rename in quotes, along with the name we want to give it, once again in quotes. In this case lets rename a fie named Cat into My Cat.

Cat.txt -> My Cat.txt

Remember to include the extension of your file as well, in this case .txt.

Ren “Cat.txt” “My Cat.txt”

If the file you want to rename does not contain any spaces within its name, surrounding its name in quotes is not necessary.

Keep in mind that the above command will only work if the file you want to rename is located I your current directory, we are going to learn how to rename our files from  any directory later on.

Optionally, you can use the dir command to verify that your file has been renamed.


Your file should now appear with its new name. Success!

Play Video

There's an easier way!

Learn the ins and outs of the windows command line with our windows command line course.

Renaming Folders – Using CMD (Ren):

Renaming folders from the command line is just as easy as renaming files. Lets rename a folder named My Folder into Renamed Folder.

My Folder -> Renamed Folder

Just like before, use the Ren command followed by the name of the file you want to rename along with the name you want it to have. Surround the names of both files within quotes.

Ren “My Folder” “Renamed Folder”

Your file should be renamed at once, optionally you can use the Dir command do verify.

In case you are wondering the quotes tell the command line that the spaces separating the words, do not constitute an additional parameter and are just a continuation of the names of our folders. So, using quotes is necessary when the names of our files or folders contain spaces.

Changing File Extensions - Using CMD:

Apart from simply changing the names of our files, using the Ren command we can also change their extension.

For example, lets make a text document into a Microsoft word document. Text documents use the .txt extension while word documents use .docx.

.txt -> .docx

Here is what our command would look like:

Ren “Document.txt” “Document.Docx”

As you can see, all we had to do is replace the extension of our file, and it can now be opened with Microsoft word.

To make this command work for you simply replace the names in the above command with your own.

Once again this command will only work if your file is located in your current directory.

Rename From Different directories:

While that is all well and good, what if the files you want to rename are in a different directory than the one you are currently on? Apart from simply navigating there using the cd command like we learned at the start of this guide, we can include the directory of our file or folder into the Ren command.

Lets suppose that the file we want rename is located at our desktop directory which is C:\Users\Username\Desktop. In your case your username will be in place of .

To rename a file named “My File” without navigating to the desktop directory all we have to do is include the location of our file before its name. Here is what that would look like:

Ren “C:\Users\Username\Desktop\My File.txt” “Renamed File.txt”

Remember to use quotes incase there any spaces in either the name of your file/folder or its location.

Use the exact same syntax to rename a folder instead of a file.

Easy as pie!


Renames a text file named Cat into My Cat.

Ren “Cat.txt” “My Cat.txt”

Changes the extension of a file from .txt to .docx.

Ren “Document.txt” “Document.Docx”

Renames a folder named My Folder to Renamed Folder.

Ren “My Folder” “Renamed Folder”

Rename a file located in the desktop directory from My to Renamed File.txt. Replace <Username> with your computer’s username.

Ren “C:\Users\<Username>\Desktop\My File.txt” “Renamed File.txt”


  • Use the CD and Dir command to navigate to the location of the file or folder you wan to rename.
  • Use Ren command to rename or change the extensions of your files and folders.
  • If the name of your file or folders contains a space within it you need to surround it in quotes.

That's It!


You now know how to rename and change the extensions of your files and folders directly from the command prompt.

If you liked this short guide take a look at a few of our other posts related to the windows command line, or if you really liked it consider enrolling in our video course where you will learn the ins and outs of the Windows command Line.

Play Video
Dont Stop Learning!

Windows Command Line Course!

This course has everything you need to start learning about the windows command line along with batch scripting.

Read More:

Any Questions? Ask them Below:

Leave a Reply

Your email address will not be published.

Take Your Skills to the next level!
Become one of our beloved students by enrolling into one of our courses. Get started now!


Take A Look At Our Command Line Course!

Need Help?

There's an easier way!


You are now officially on your way to becoming a genius!