[Solved] PowerShell batch rename with regex?


try this (remove whatif)

Get-ChildItem "c:\temp" -file -Filter "*.txt" | where BaseName -Match ".-." | %{
$newname="{0}{1}" -f ($_.BaseName -split '-')[1], $_.Extension
Rename-Item $_.FullName $newname -WhatIf
}

4

solved PowerShell batch rename with regex?