It'd be much better to actually use the os commands to split/join the base and extension than assume the filename doesn't contain any extra dots