How to Rename a File and Folder from the Command Prompt

   Information
This will show you how to rename a file and folder using the REN or RENAME command from within a command prompt. This can be handy if you cannot rename the file or folder normally.

Normally you would just right click on the file or folder, click on Rename, and type in a new name for it.
   Note
While you can run this command in a non-elevated or elevated command prompt, you would get the best results using a elevated command prompt.

EXAMPLE: REN and RENAME Command
NOTE: You can use either the REN or RENAME command in the command prompt. They are the same command.
File and Folder - Rename from Command Prompt-about_ren_rename.jpg





OPTION ONE

To Rename a File from the Command Prompt


1. To Use a Elevated Command Prompt in Windows
A) Make sure that the file is not set to be hidden.
B) Open Folder Options and uncheck the Hide extensions for known file types option and click on OK. (see screenshot below)
NOTE: This way you will be able to see the file extension in your file's name to use in the command below.
File and Folder - Rename from Command Prompt-folder_options.jpg
C) Open a elevated command prompt.

D) Go to step 3.
2. To Use a Command Prompt at Boot
A) Open a command prompt at boot.

B) In the command prompt, type diskpart and press Enter. (see screenshot below)

C) In the command prompt, type list volume and press Enter. (see screenshot below)
NOTE: This will let you see what the drive letter is for the drive that you want to delete the file in since it may not always be the same drive letter that it is in Windows.

D) After making note of the drive letter, type exit and press Enter. (see screenshot below)
File and Folder - Rename from Command Prompt-boot-1.jpg
3. In the command prompt, type the command below and press enter.
NOTE: Substitute Full Path of File with extension within quotes below with your files's full path and name with the extension included within quotes instead. Substitute New File Name with extention within quotes below with only the new name and file extension you want to rename the file with.

Code:
REN "Full Path of File with extension" "New File Name with extension"
NOTE: For example, if I wanted to rename a text file named File1 with the file extenstion .txt on my desktop to File2 with it keeping the same .txt file extension, I would type this command below.

Code:
REN "C:\Users\UserName\Desktop\File1.txt" "File2.txt"
File and Folder - Rename from Command Prompt-rename_file.jpg
4. The file should now be renamed. Close the command prompt.





OPTION TWO

To Rename a Folder from the Command Prompt


1. To Use a Elevated Command Prompt in Windows
A) Make sure that the folder is not set to be hidden.
B) Open a elevated command prompt.

C) Go to step 3.
2. To Use a Command Prompt at Boot
A) Open a command prompt at boot.

B) In the command prompt, type diskpart and press Enter. (see screenshot below)

C) In the command prompt, type list volume and press Enter. (see screenshot below)
NOTE: This will let you see what the drive letter is for the drive that you want to delete the file in since it may not always be the same drive letter that it is in Windows.

D) After making note of the drive letter, type exit and press Enter. (see screenshot below)
File and Folder - Rename from Command Prompt-boot-1.jpg
3. In the command prompt, type the command below and press enter.
NOTE: Substitute Full Path of Folder within quotes below with your folder's full path and name within quotes instead. Substitute New Folder Name within quotes below with only the new name you want to rename the folder with.

Code:
REN "Full Path of Folder" "New Folder Name"
NOTE: For example, if I wanted to rename a folder named Folder Name1 on my desktop to Folder Name2, I would type this command below.

Code:
REN "C:\Users\UserName\Desktop\Folder Name1" "Folder Name2"
File and Folder - Rename from Command Prompt-rename_folder.jpg
4. The folder should now be renamed. Close the command prompt.
That's it,
Shawn