Manage & Troubleshoot Networks – From the Windows Command Line (CMD, DOS)
This guide is all about various cmd commands you can use to manage and troubleshoot networks directly from the windows command line.
Welcome!
This short guide is all about renaming files and folders from the windows command prompt (cmd).
Lets get started!
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.
For example, lets assume that the file or folder we want to rename is located in our desktop.
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.
Dir
The name of every file and folder as well some information about each one of them will appear.
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.
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 fle you wan to rename is located I your current directory, we are going to learn houw to rename our files from any directory later on.
Optionally, you can use the dir command to verify that your file has been renamed.
Dir
Your file should now appear with its new name. Success!
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.
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.
While that is all well and good, what if the files you want to rename are in a different directory that 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 dire 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 <Username>.
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 File.tt to Renamed File.txt. Replace <Username> with your computer’s username.
Ren “C:\Users\<Username>\Desktop\My File.txt” “Renamed File.txt”
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.
This course has everything you need to start learning about the windows command line along with batch scripting.
This guide is all about various cmd commands you can use to manage and troubleshoot networks directly from the windows command line.
A redirector or pipe is a special symbol that is used to redirect the input or output of a command or combine two or more commands in various ways.
The shutdown command can be used to create shutdown timers, restart your system, log out or even to open the advanced start options menu.
Learn the Windows command line And Become an Expert!