Batch Rename Files in Windows Using PowerShell

Published on March 2, 2020 at 4:12:11 AM GMT+8 by Administrator

This article demonstrate the command to batch rename files using Windows PowerShell


Batch Rename Files in Windows Using PowerShell

Using Windows Powershell

Windows Powershell is far more powerful than the regular command prompt and is also easy to use. To batch rename files using Powershell, we need to use two commands, i.e. DIR and Rename-Item. Now to batch rename without changing their extensions, press the WIN button, type “powershell” and press enter button to open Powershell.

Once the Windows Powershell is opened, navigate to your desired directory using CD command. As for me, I’m navigating to D:\mte\ as this is where my files are located.

Once you are in the location, use the below command. While using the command, don’t forget to change “TestName” to your desired file name.

batch-rename-files-windows-powershell-rename

What the above command does is that it will take all the files in the directory using the DIR command and pass to the “Rename-Item” command which renames all the files to “TestName*.” Here * denotes numbers, and those numbers are allocated recursively using “$x.”

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

batch-rename-files-win-powershell-change-extension

What the above command does is take all the files with .html extension in a directory and change them to .txt.

batch-rename-files-win-powershell-changed-extension

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