johnyk105
johnyk105

Reputation: 9

Rename all files to .txt

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

Answers (2)

dvint1
dvint1

Reputation: 21

You can try:

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

Upvotes: 1

phuclv
phuclv

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

Related Questions