Windows

How to rename files with Command Prompt and PowerShell

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button