[Solved] PowerShell batch rename with regex?

[ad_1]

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

[ad_2]

solved PowerShell batch rename with regex?