Hi,
Please check to see if this works.
$folder = 'C:\temp\'
Get-ChildItem -Path $folder|ForEach-Object{
$array = $_.BaseName -split ' '
$newname = $array[-1] + ' - '+ ($array[0..($array.count-2)] -join ' ') + $_.Extension
Rename-Item -Path $_.FullName -NewName $newname
}
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.