Multiple file rename using regular expression

I have a bunch of episode files in my directory that I would like to rename to proper S[XX]E[YY] format.

Current directory listing looks like this:

S1 Episode 10.avi S1 Episode 11.avi S1 Episode 12.avi S1 Episode 13.avi S1 Episode 14.avi S1 Episode 15.avi S1 Episode 16.avi S1 Episode 17.avi S1 Episode 18.avi S1 Episode 19.avi S1 Episode 1.avi S1 Episode 20.avi S1 Episode 21.avi S1 Episode 22.avi S1 Episode 23.avi S1 Episode 24.avi S1 Episode 25.avi S1 Episode 26.avi S1 Episode 27.avi S1 Episode 28.avi S1 Episode 2.avi S1 Episode 3.avi S1 Episode 4.avi S1 Episode 5.avi S1 Episode 6.avi S1 Episode 7.avi S1 Episode 8.avi S1 Episode 9.avi S2 Episode 10.avi S2 Episode 11.avi S2 Episode 12.avi S2 Episode 13.avi S2 Episode 14.avi S2 Episode 15.avi S2 Episode 16.avi S2 Episode 17.avi S2 Episode 18.avi S2 Episode 19.avi S2 Episode 1.avi S2 Episode 20.avi S2 Episode 21.avi S2 Episode 22.avi S2 Episode 23.avi S2 Episode 24.avi S2 Episode 2.avi S2 Episode 3.avi S2 Episode 4.avi S2 Episode 5.avi S2 Episode 6.avi S2 Episode 7.avi S2 Episode 8.avi S2 Episode 9.avi S3 Episode 10.avi S3 Episode 11.avi S3 Episode 12.avi S3 Episode 13.avi S3 Episode 14.avi S3 Episode 15.avi S3 Episode 16.avi S3 Episode 17.avi S3 Episode 18.avi S3 Episode 19.avi S3 Episode 1.avi S3 Episode 20.avi S3 Episode 21.avi S3 Episode 22.avi S3 Episode 23.avi S3 Episode 24.avi S3 Episode 2.avi S3 Episode 3.avi S3 Episode 4.avi S3 Episode 4.avi S3 Episode 6.avi S3 Episode 7.avi S3 Episode 8.avi S3 Episode 9.avi

Continue reading “Multiple file rename using regular expression”