Rename problem

I suspect the problem is above the keyboard on this one.

I download what little tv I watch and all the .avi files go into one folder. To make it more reasonable to find shows in Windows Media Center, I rename the files to a specific format.

I start out with file names that look like this:

detroit.1-8-7.s01e05.hdtv.xvid-2hd.avi
castle.2009.s03e05.hdtv-lol.avi

And want to end up with file names that look like this:

Detroit 1-8-7 s01e05.avi
Castle 2009 s03e05.avi

So I'm trying to remove the extraneous strings and replace periods with spaces and titlecase the remaining words.

Here's the button script so far:

@NoDeselect
Rename CASE=allwords
Rename PATTERN="hdtv xvid-lol" TO="." FINDREP
Rename PATTERN="hdtv-lol" TO="." FINDREP
Rename PATTERN="hdtv.xvid-2hd" TO="." FINDREP
Rename PATTERN="." TO=" " FINDREP
Rename PATTERN="^( +)(.)( +)(..)" to "\2\4" FINDREP

At this point the last line isn't working - I'm still ending up with trailing spaces at the end of the filename. Ideally I'd like to get the season 's' lowercase too - it's the first s in 'so3e05'

Any suggestions? I've looked at lots of samples in the forums and have tried lots of combinations but no luck yet.