fixed issue with splitting filenames with a . in them
split filenames using rsplit to correctly take out the extension