I'm trying to rename all files of a directory, remove parts of files names excluding some parts.
for example:
Before --> Afterfile1: Something S01E01 Hello There Guys.srt --> S01E01.srt
file2: Something_else S03E22 Good.bye.srt --> S03E22.srt
etc.
I tried following code in powershell:
Get-ChildItem | rename-item -NewName {$_.name -replace "Something",""}
Get-ChildItem | rename-item -NewName {$_.name -replace "Good.bye",""}
Get-ChildItem | rename-item -NewName {$_.name -replace "Something_else",""}
Get-ChildItem | rename-item -NewName {$_.name -replace " Hello(.*?)\.srt",".srt"}
Get-ChildItem | rename-item -NewName {$_.name -replace " ",""}
Any idea about the right regex code instead of hardcoding to exclude "SxxExx.srt" Part of file name and remove the other parts of name?