Try path.os.basename/split instead of string.rsplit