Andy Nguyen
Andy Nguyen

Reputation: 1

Renaming only certain part of a file name

I need to write a powershell script to rename only a certain part of a file name.

MTR needs to be changed to MTE, only the R needs changing, all others letters/numbers needs to stay the same.

Original file name FILEORIG.MTR001

File needs to be changed to FILEORIG.MTE001

Any help will be much appreciated.

Upvotes: 0

Views: 52

Answers (1)

Drew
Drew

Reputation: 4020

Since you did not provide code I cant get you a ready to go script but this is the command you are after once you locate the file and pipe it..

<# Your Code Here, Probably a Get-ChildItem #> | Rename-Item -NewName {$_.name -replace "MTR","MTE"}

Upvotes: 1

Related Questions