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?
One simple solution is to run rename-item
with -WhatIf
. This will display something like
PS H:\test> gci | rename-item -newname { $_.name -replace 'temp','test' } -WhatIf
What if: Performing operation "Rename File" on Target "Item: H:\test\temp1 Destination: H:\test\test1".
Good enough, or do you need it to do it while also doing the operation?
EDIT: An even simpler solution, use -Verbose
. Does the same as the -WhatIf
, but also performing the operation :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With