How to rename files with Command Prompt and PowerShell
July 28, 2021
0 7 3 minutes read
In a previous post we have seen that you can rename files in bulk with the File Explorer in Windows 10. This time we will see that you can also rename files individually and in bulk using the Command Prompt or PowerShell.
With the Command Prompt (CMD) and PowerShell you have two additional alternatives to rename a file or several at the same time. Although there are a number of ways you can manipulate files with these scripting tools, the instructions below are based on the most common scenarios. This is enough to rename a file or rename files in bulk.
Rename a file with CMD
# 1. Open Command Prompt.
# 2. Write the following command changing the path to the folder with the files you want to rename, and press Enter.
cd% USERPROFILE% \ Desktop \ caminogeek
This example opens the folder caminogeek, which is on my Desktop. Replace the path with the location of your files.
# 3. To see the list of files in that folder, type the dir command and press Enter.
# 4. To rename one of the files, use the following command (replacing �currentname.extension� and �newname.extension�) and press Enter:
ren "currentname.extension" "newname.extension"
Quotation marks are only needed in case the name includes spaces.
ren 6GULZKR1.jpg"wp-block-image size-large">
If you want to rename the other files, you will have to repeat that last step as many times as necessary, substituting the file names in each case. But you can also rename the files in bulk with the Command Prompt as shown in the next section.
Rename files in bulk with CMD
# 1. Search for Command Prompt in Windows search or Start menu and choose the main result.
# 2. Write the following command changing the path to the folder with the files you want to rename, and press Enter.
cd% USERPROFILE% \ Desktop \ caminogeek
This example opens the folder caminogeek, which is on my Desktop. Replace the path with the location of your files.
# 3. Type the dir command and press Enter to list the files in the folder.
# 4. Type the following command to rename the files in bulk and hit Enter:
ren *.extension??? - newname. *
The following example will rename all the.JPG files, keeping the first 3 characters.
ren *.jpg"vertical-align: inherit;"># 5. Type the dir command and hit Enter to list the files in the folder already renamed in bulk.
dir
[ * ] It is a wildcard command ordering ren rename everything that has a particular extension (eg:.jpg"vertical-align: inherit;">[?] is a wildcard that represents a character from the original name, which would function as a unique identifier to avoid duplication of names.
Upon completing the above steps, the files will be renamed according to the specified name and criteria.
Rename file with PowerSheell
To rename a single file using PowerShell, follow these instructions:
# 1. Find PowerSheell in the start menu and choose the main result.
# 2. Type the following commands to go to the folder and list the files you want to rename and hit the Enter key after each one.
Cd Desktop \ caminogeek
Dir
The first command opens the folder caminogeek found on my desktop. Remember to substitute the path to match the folder where your files are located.
# 3. Type the following command to rename a file and hit Enter. Quotation marks are only required if the file includes spaces in its name.
Rename-Item "current-name.extension" "new name.extension"
Rename-Item 6GULZKR.jpg"wp-block-image size-large">The above example renames the file 6GULZKR.jpg"vertical-align: inherit;">If you want to continue renaming the other files in this way, you will have to repeat step 3 with the respective names of each file and the new one in each case.
Rename files in bulk with PowerShell
# 1. Open PowerShell using start menu search.
# 2. Type the following commands to go to the folder with the files and list them, pressing Enter after each command.
Cd Desktop \ caminogeek (change to the path of your files)
Dir
# 3. Type the following command to rename the files simultaneously and hit Enter.
Dir | % {Rename-Item $ _ -NewName ("caminogeek {0}.extension" -f $ nr ++)}
This example renames images that have a.jpg"vertical-align: inherit;">Remember to change the name (caminogeek, in the example) to the one you want in your case.
When you complete the steps, all files that meet the criteria will be renamed with the new name, differentiated by a different number at the end.
It is very good to have alternatives to do things, in this case using both the Command Prompt and PowerShell to rename files. But if you are going to rename a file or rename files in bulk, the easiest and most direct way is using Windows File Explorer.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.