Deployn

Efficiently Rename Multiple Files at Once in Windows

Streamline your workflow by learning how to quickly rename batches of files in Windows 10 and 11.

Efficiently Rename Multiple Files at Once in Windows-heroimage

CAUTION

Please be aware that this blog post was initially composed in German and translated for your convenience. While every effort has been made to maintain accuracy, there may be some translation errors. I apologize for any misunderstandings this may cause and welcome any corrections via comments or email.

Streamlining File Management

Renaming files individually can be a painstaking task. But worry not—Windows provides efficient solutions to batch rename files. This article will give you a rundown of built-in methods that require no additional software, followed by an exploration of other tools.

Built-in Windows Techniques for Bulk Renaming

Quick Renaming with Windows Explorer

The simplest tool at your disposal is Windows Explorer. Here’s how to use it:

  1. Open File Explorer Win + E.
  2. Navigate to the directory containing your target files.
  3. Select the files to be renamed. To select all files, use Ctrl + A. For multiple selections, hold Ctrl and click on the desired files.
  4. Press F2 or right-click on a selected file and choose “Rename” from the context menu.
  5. Type in the new name for the group of files and press Enter.

File-Explorer

This method works great when you want to assign the same base name to a group of files. An added benefit is the ability to undo changes with Ctrl + Z. Many articles I found, only mention this procedure. However, this is a basic method and may not suffice for more complex renaming needs.

Command Prompt (CMD) Renaming

For more control, turn to the command prompt:

  1. Open the command prompt via the Start menu or with Win + R, then type “cmd”.
  2. Navigate to your folder using cd. You can change the directory with cd followed by the directory name. Use cd .. to move up a level. If you are in your personal user folder, you can change to the desktop directory with cd Desktop. Folders with spaces need to be enclosed in quotes. Verify your files are present with dir.
  3. Utilize ren to rename files.

For instance:

ren old-file.txt new-file.txt

To rename multiple files, chain commands together:

ren old-file.txt new-file.txt & ren old-file2.txt new-file2.txt

Placeholders like * for any string and ? for a single character can help with broader changes:

ren *.txt *.md

CMD

Unfortunately, this method is not very flexible if you want to rename several files with different names.

It is possible to save ren commands in a batch file and execute them.

For example, I create a text file named rename.txt and insert the following content.

@echo off
setlocal enabledelayedexpansion

for %%F in (*.txt) do (
  set "filename=%%~nF"
  ren "%%F" "new_!filename!.txt"
)

endlocal

After the file and its contents have been saved, I change the file extension from .txt to .bat. Now I can execute the file, and all files with the extension .txt are renamed new_*.txt.

Elevated Renaming with PowerShell

PowerShell, a robust scripting language within Windows, takes renaming to another level, offering flexibility and power. Here’s how to leverage it:

  1. Open the desired folder in File Explorer.

  2. Open PowerShell in your target folder by holding Shift and right-clicking, then choosing “Open PowerShell window here.” You can also navigate using cd.

Open PowerShell

  1. Use the command Get-ChildItem to list all files in the current directory. With Get-ChildItem *.txt all files with the extension .txt are listed. Get-ChildItem -File lists all files.

  2. Rename using Rename-Item.

PowerShell can accomplish a variety of tasks:

Add Prefixes

Get-ChildItem -File | Rename-Item -NewName { "hallo_" + $_.Name }

This adds the prefix “hallo_” to all files.

Add Suffixes

Get-ChildItem *.txt | Rename-Item -NewName { $_.Name + "_hallo" }

This adds the suffix “_hallo” to all files with the extension .txt. This means the file file.txt is renamed file.txt_hallo. However, this is probably not the desired result. The file name must be broken down into components to achieve this.

Get-ChildItem *.txt | Rename-Item -NewName { $_.BaseName + "_hallo" + $_.Extension }

Delete characters

Get-ChildItem -File | Rename-Item -NewName { $_.Name.Remove(0, 5) }

This removes the first 5 characters from all files (regardless of the extension).

Add characters

Get-ChildItem -File | Rename-Item -NewName { $_.Name.Insert(2, "test_") }

This inserts the string “test_” after the second position in the name of all files.

Replacing part of the name

Get-ChildItem *.txt | Rename-Item -NewName { $_.Name -replace 'file', 'new-file' }

This command renames all files with the extension .txt by replacing the string “file” with “new-file”. This means that the file file.txt is renamed to new-file.txt and the file textfile.txt is renamed to textnew-file.txt. The files nocheine.txt and exceldatei.xlsx remain unchanged.

Add random characters

Get-ChildItem -File | Rename-Item -NewName { $_.Name.Insert(0, [System.IO.Path]::GetRandomFileName()) }

This inserts a random string as a prefix for all files.

Random Naming

Get-ChildItem -File | Rename-Item -NewName { $_.Name -replace $_.BaseName, [System.IO.Path]::GetRandomFileName() }

This randomly renames all files. The file extension is retained.

File names in capital letters

Get-ChildItem -File | Rename-Item -NewName { $_.BaseName.ToUpper() + $_.Extension }

This renames all files to upper case.

File names in lowercase letters

Get-ChildItem -File | Rename-Item -NewName { $_.BaseName.ToLower() + $_.Extension }

This renames all files to lowercase.

Remove spaces

Get-ChildItem -File | Rename-Item -NewName { $_.Name -replace ' ', '' }

This removes all spaces from the file names.

Last modified date as a prefix

Get-ChildItem -File | Rename-Item -NewName { $_.LastWriteTime.ToString("yyyyMMdd") + "_" + $_.Name }

This adds the last write access date as a prefix to all files.

File size as prefix

Get-ChildItem -File | Rename-Item -NewName { "Size_" + $_.Length + "_" + $_.Name }

This adds the file size in bytes as a prefix to all files.

Folder name as prefix

Get-ChildItem -File | Rename-Item -NewName { $_.Directory.Name + "_" + $\_.Name }

This adds the parent folder’s name as a prefix to all files.

For a deep dive into Rename-Item, check out the Microsoft documentation.

Additional Tools and Techniques

In addition to the integrated methods, other software can be used to rename multiple files in Windows.

Excel for Batch Renaming

For extensive lists of file names, Excel can work in tandem with PowerShell to handle complex renaming:

  1. Export file names to CSV using PowerShell:
Get-ChildItem -File | Select-Object Name | Export-Csv -Path .output.csv -NoTypeInformation
  1. Open the CSV in Excel.

A table can now be created from which the file names can be changed. Formulas can also be used to change the file names.

In my case, I have the exported file names in column A (Name) and the new file names in column B (NewName). Column B can also remain empty if the file names are not to be changed. The file extension must be retained.

  1. Create a third column with a formula that renames the files. To do this, use the function CHAR(34) to insert quotation marks into the formula. The formula in cell C2 then looks like this:
=SWITCH(TRUE, LEN(B2)>1, "Rename-Item -Path " & CHAR(34) & A2 & CHAR(34) & " -NewName " & CHAR(34) & B2 & CHAR(34),"")

The formula can then be copied down.

Excel formula

  1. Copy the generated PowerShell command (without the heading) and execute them to rename files.

  2. The files are renamed.

Third-party Software Solutions

For those seeking a more user-friendly interface or advanced features, consider third-party tools, such as (in alphabetical order):

A standout is Microsoft’s own PowerToys, which includes the “PowerRename” utility.

PowerRename with PowerToys

PowerToys offers a suite of utilities for Windows 10 and 11. You can download the latest version here.

Use the “PowerRename” feature directly from the context menu. The tool offers a very user-friendly interface and many useful functions.

PowerRename

The free tool displays the new name on the right. The spelling (upper and lower case, etc.) can also be adjusted with a click. Numbering can be added.

Renaming Safeguards

When renaming files in bulk, take these precautions:

  • Back up data to prevent loss.
  • Test renaming methods on a small group first.
  • Be cautious with wildcards or regex to avoid unintended changes.

Final Thoughts

Renaming files en masse needn’t be a chore. With these strategies, you can quickly alter file names across Windows systems. Share other tips, questions, or suggestions in the comments!


This website uses cookies. These are necessary for the functionality of the website. You can find more information in the privacy policy