I was looking for a way adjust the following:
- Name S01e01.mp4
- Name s01e02.mp4
- Name s01e03.mp4
Is there a way to capitalize the S and E ??
- Name S01E01.mp4
- Name S01E02.mp4
- Name S01E03.mp4
I have tried the below but it replaces all E's resulting in:
dir -recurse | where {-Not $_.PsIscontainer -AND $_.name -match "."} |
foreach {
$New=$_.Basename.Replace(" s"," S").Replace("e","E")+$_.Extension
Rename-Item -path $_.Fullname -newname $New -passthru
}
- NamE S01E01.mp4
- NamE S01E02.mp4
- NamE S01E03.mp4
Thank you so much in advance.
UPDATE:
cd C:\Users\test\Desktop\test
PS C:\Users\test\Desktop\test> dir -recurse | where {-Not $_.PsIscontainer -AND $_.name -match "."} |
>> foreach {
>> $New = $_.Name -replace '(.* )s(\d{2})e(\d{2}\..*)', '$1S$2E$3'
>> Rename-Item -path $_.Fullname -newname $New -passthru
>> }
Directory: C:\Users\test\Desktop\test
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 1/25/2018 2:32 PM 0 Test.Of.Testing.S01e01.this.X264.Mp4
-a---- 1/25/2018 2:32 PM 0 Test.Of.Testing.S01E01.this.X264.Mp4
-a---- 1/25/2018 2:33 PM 0 Test.Of.Testing.S01e31.this.X264.Mp4
-a---- 1/25/2018 2:33 PM 0 Test.Of.Testing.s01E01.this.X264.Mp4
This is what I currently get after swapping in the suggestion from mklement0, it almost looks like nothing changes?
Thanks