Computer >> Computer tutorials >  >> System >> windows

3 Ways to Batch Rename Files in Windows

3 Ways to Batch Rename Files in Windows

With our growing collections of digital files, it’s a nightmare when you want to rename a bunch of files to make them easier to find. Naming dozens or hundreds of similar files one at a time takes forever. Luckily, there are several significantly easier ways to batch rename files in Windows to save time and headaches.

While I’ll include a few third-party tool suggestions at the end, you usually don’t need to install extra software. Instead, use the built-in tools in Windows.

Using File Explorer

Using File Explorer to batch rename files in Windows is usually the easiest way. To batch rename files, just select all the files you want to rename, press the F2 (alternatively, right-click and select rename), then enter the name you want on the first file. Press Enter to change the names for all other selected files.

3 Ways to Batch Rename Files in Windows

For example, I had a list of images that I wanted to change from the default date-naming convention to something simpler to read. In this case, January 2021. This method adds sequential numbers in parentheses beside each file name. This is a great way to keep similar files together, such as a project, photos from a trip, or anything else.

3 Ways to Batch Rename Files in Windows

It’s that easy to rename files using File Explorer, but this method is just basic and is not so flexible, e.g., you cannot change the file extensions (.html) and cannot restrict or change Windows from adding numbers, etc. For more advanced functions, we need to use the command prompt and Windows PowerShell.

Using the Command Prompt

If you want to batch rename only the extensions in Windows, the command prompt is a great tool. You can also rename files. Let’s first tackle changing extensions.

Originally, you could quickly access the command prompt option via the File menu in File Explorer, but Windows 10 eventually removed that option. There are still other ways to access command prompt.

1. Open command prompt by pressing Win + R, typing “cmd” and pressing OK.

3 Ways to Batch Rename Files in Windows

2. Once the command prompt window opens, you’ll need to change the directory to the folder where your files are located. You can type in the full path or open the folder in File Explorer. Right-click the path location above the file list and choose “Copy address.”

3 Ways to Batch Rename Files in Windows

You can then copy this into the command prompt. Before you type or copy anything, type cd and then the path location.

If you’re having trouble with copy and paste, you may need to change the settings to enable the copy and paste function in command prompt.

3 Ways to Batch Rename Files in Windows

Enter the following command using the file extensions you want:

ren *.fileext1 *.fileext2

In my case, I’m changing the .jpg extension to .png. Please note this doesn’t actually change the file type, just the extension.

3 Ways to Batch Rename Files in Windows

If you want to batch rename the file names, it’s a similar process. However, if the file names share numerous characters, you may get an error concerning duplicate files. To make sure this doesn’t happen, use wildcards, which are question marks, to keep a unique portion of the original name.

In my example, my files all start with 01. Some files share as many ten characters.

After changing the command prompt directory to the folder with your files, enter the following:

ren *.fileext ???name.fileext

Enter as many ? as you need for the characters. If you want a space in your file name, place the file name in quotes, such as “???File Name.jpg.” If you want your new file name at the beginning, use the wildcards after the file name, such as FileName????. In my case, I’d use:

ren *.jpg ?????????January.jpg
3 Ways to Batch Rename Files in Windows

This method can be tricky. If all the files don’t have the same file name length originally, only part of the files will change.

Using Windows PowerShell

Windows PowerShell is far more powerful than the regular command prompt and is also easy to use, though the two are somewhat similar. To batch rename files in Windows using PowerShell, you only need a few simple commands.

Open the folder where your files are located in File Explorer. Open File and choose “Open Windows PowerShell.”

3 Ways to Batch Rename Files in Windows

Once PowerShell is open, use the below command. While using the command, don’t forget to change “TestName” to your desired file name and use the correct file extension.

dir | %{$x=0} {Rename-Item $_ -NewName "TestName$x.jpg"; $x++ }
3 Ways to Batch Rename Files in Windows 3 Ways to Batch Rename Files in Windows

The above command will take all the files in the directory and pass them to the Rename-Item command, which renames all the files to “TestName*.” Here * denotes numbers, and those numbers are allocated recursively using “$x.” This allows each file to have a unique name.

If you want to change the file extensions of all the files in a directory, use the below command.

Get-ChildItem *.jpg | Rename-Item -NewName { $_.Name -replace '.jpg','.png' }
3 Ways to Batch Rename Files in Windows

What the above command does is take all the files with the .jpg extension in a directory and changes them to .png.

3 Ways to Batch Rename Files in Windows

To know more about Rename-Item command, read the Microsoft documentation for more definitions and examples.

Which of the above three methods do your prefer?? Sure, PowerShell may be overwhelming for beginners, but it is fun to work with once you’ve gained some experience. You can even uninstall those pesky preinstalled apps.

Hopefully that helps, but do share your thoughts and other methods of manually batch-renaming files. You might also want to learn how to create symbolic links to files for quick access. Also, if you’re planning move files around in bulk in File Explorer, explore these easy ways to copy a large number of files quickly.