PowerCLIvHersey

PowerShell Basic – Quick Mass Filename Rename

Just a quick snip of PowerShell for renaming files or folders in mass.

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


Get-ChildItem returns all the files in the current directory. The -Recurse parameter also returns files and folders in any subfolders.

Here is the output of Get-ChildItem from my current directory.
PS-Get-ChildItem

I want to rename all the files replacing the part of the name containing “7005N” with “B05328”. The Rename-Item -NewName gets the name from Get-ChildItem and performs a replace to replace the part of the filename matching 7005N with B05328 in the current folder and any subfolders.

PS-Rename-Item

Quick and handy.

Leave a Reply

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

fifteen + 15 =