parse_filename: Fixed issues when file name contains dots.

Unfortunately the code of `parse_filename` seems to be duplicated. This patch should fix problems that arise when the file name contains dots. Obviously `name = fname.split('.')[0]` will not work in this case.

This should fix issue #6260.