I'd like to select a list of files using Get-ChildItem
piped to Rename-Item
and have the output display text with each line showing something like "Renamed oldfilename to newfilename".
How can I do this?
Get-Childitem C:\Temp |
Foreach-object {
$OldName = $_.name;
$NewName = $_.name -replace 'temp','test';
Rename-Item -Newname $NewName;
Write-Output $("Renamed {0} to {1}" -f $OldName,$NewName)
}