Home > Software engineering >  Rename all files to .txt
Rename all files to .txt

Time:11-27

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

CodePudding user response:

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

CodePudding user response:

You can try:

Get-ChildItem c:\temp\*.* | Rename-Item -NewName { $_.Name -replace $_.Extension,'.txt' }
  • Related