I'm wondering if there already exists software that enables (or a database that *would* enable) you to determine a file's/title's episode number based on the file's metadata (runtime, title number, disc number, season, number of chapters, screen-shot matching, etc) and, of course, rename it. The last part is easy and I've come across a number of scripts that will do that, not exactly rocket science, but figuring out the actual episode number is a "bit" trickier.
Is there already something like that out there?