'Bash - Renaming episode names to remove junk [duplicate]

When I am looking at episode names, often they're in the format of:

The.Show.Name.S06E01.lots.of.junk-often_with_chars.mkv
The.Show.Name.S06E02.lots.of.junk-often_with_chars.avi
Show.Name.S06E03.lots.of.junk-often_with_chars.mp4

I'd like to end up with a simple:

Show Name S06E01.mkv
Show Name S06E02.avi
Show Name S06E03.mp4

Ideas on a simple bash command or two I could run to clean up all the junk, remove the periods other than the end, allow for any three-digit file extension?

Thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source