Thanks. This is the second time I made the same mistake. haha.
One slight correction is that it seems the array index starts at 0, so I need [1] rather than [2].
Is there any way to parse the filename using
(.*\dE\d* )(.*)( 1080p.*\.mkv)
so I can just use $2 (or point to (.*) ) instead of $_.name.split('.')[1]?
It would just be more elegant to have a solution that didn’t require me to rename the file names twice, meaning adding a period so I can use split(‘.’) and then removing the periods afterwards.
But thanks for pointing out the need for the additional $().
I added the periods after the SxxExx and before the 1080p so the split would place the entire episode title in one array element, since the episode title varies in length and is always bound between these two identifiers.
Alternatively, I could have files with names where each empty space has been replaced with periods, which is standard for some people. In either instance, the split solution only works if the episode title contains no periods.
And, yes, I will clean up the code. I thought i had used the proper escape characters when I submitted the question, but clearly didn’t and I just haven’t had the time until now.
* is not a valid character for a file. I’ll assume that you mean
Series_name SxxExx Episode_Title 1080p.mkv
which may render my suggestion useless if my assumption is incorrect. But if there is not a space in the title and you can depend on there being only space after it (the one directly after it) then this could be simplified to
Please note that I didn’t use the aliases. They are fine when just typing in the console but for shared/production scripts it is frowned upon to use them.