I need to swap the names of some files. The files are in the same location so I planned to move them to a staging ground to avoid having two files with the same name. I am attempting to identify the file, based on name parameters, move it to the staging ground and rename it.
I would like to use something similar to the following:
Get-ChildItem ".\" -Recurse | Where-Object { $_.Name -like "*XYZ*"} | Move-Item -Force -Destination "C:\new\" | Rename-Item -NewName { $_.Name -replace 'XYZ','ABC' }
The file moves, but does not rename. Am I not able to pipe the move-item to rename-item?
I would be happy to know if there is a better way to swap the file names of two files without moving, but also would like to know why the above isn't working.
Thanks!