Reputation: 9
I am trying to rename all file to .txt. I have tried selecting all and renaming it only changes the name and not the extension.
Get-childitem
Rename-Item c:\temp\*.* *.txt
Upvotes: 0
Views: 632
Reputation: 21
You can try:
Get-ChildItem c:\temp\*.* | Rename-Item -NewName { $_.Name -replace $_.Extension,'.txt' }
Upvotes: 1
Reputation: 41805
Get-ChildItem C:\Temp\*.* | Rename-Item -NewName { $_.BaseName + ".txt" } -WhatIf
-WhatIf
is for confirming if the rename is correct or not. Remove that to do the real renaming
Upvotes: 3