Converting tensor into text then performing replace

Hello everyone, I have the following function:

def get_videoname(paths):

    vidname = str(paths)
    vidname = vidname.strip()
    vidname = vidname.replace('[', '')
    vidname = vidname.replace(']', '')
    vidname = vidname.replace(' ', '')
    vidname = vidname.replace(r"D:\\A\\C\\frames-KP\\dev\\", '')
    vidname = vidname.split(',')
    return vidname

and it outputs the following after I loop through the list:


How can I edit my function so I can remove *.jpg.npy

I tried re.sub(r'\(*.jpg.npy\)', '', vidname), but it doesn’t seem to work.

Wouldn’t another replace call work?
Also, how is this related to tensors?