Rename a bunch of files/directories

Reading Time: < 1 minute

This has been quite useful to me as well.

get-childitem “*.xml” | foreach { rename-item $_ $“NES-“, “NES-X”) }Replace

Get-ChildItem -path PROD -Directory | ForEach-Object -Process {Rename-item -path $_.Name -NewName ($,8)) -Verbose }
Another example:
Get-ChildItem ‘C:\Temp\crs\documents’ | rename-item -newname { $,45) + ‘_Client_Report.pdf’}

Here is a variant to add a string to an existing file name:
get-childitem “*.pdf” | foreach { rename-item $_ $$_.Basename,”LU0010001_2016_2016_08_22_14_33_17_277_” + $_.Basename) }

Leave Comment

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