I am trying to rename certain files and then copy them to a backup location as below:
gci $src `
| ?{!$_.psiscontainer -and $_.extension.length -eq 0 -and $_ -match "tmp_\d{1}$"} `
| %{ ren -path $_.fullname -new ($_.name + ".ext") } `
| %{ cpi -path $_.fullname -dest $bkup -force}
The renaming part is working fine. But the renamed files are not being copied over to the backup location. What I am doing wrong here?
By default renamed items will not be pushed back onto the pipeline, use the -PassThru switch to pass them on: