2

I have a function working very well by getting the frames from the filename.
But it takes only the last number (frame) from the file name.

An example:

Filename:
1200,4500.avi

The code made to get the last number (frames), and it can import multiple avi files from specific folder.

Here's the code:

def insert_types(out, dir):
    for root, dirs, files in walk(dir):
        for f in files:
            match = search(r"(\d*)\.avi$", f)
            if match:
                startframe = match.group(1)
                out = InsertSign(out, join(root, f), int(startframe))
    return out

out = jpop.mkv
out = insert_types(out, r"D:\path\avi_folder")
return out

InsertSign() function have an option to put the start & end frame of the file (if I'm doing it manually).

An example:

video = jpop.mkv
sign = 1200,4500.avi
startframe = 1200
endframe = 4500
final = InsertSign(video,sign, startframe,endframe)
return final

I tried many times and to find out how to change the insert_types function to take the first & last number (1200, 4500) from the file name (1200,4500.avi) at the same time ignoring the comma mark (,) which is in the file name.

I tried to do it by myself but its beyond my means ^^"

Hope someone can help me with that

Regards.

0

Instead of

            match = search(r"(\d*)\.avi$", f)
            if match:
                startframe = match.group(1)
                out = InsertSign(out, join(root, f), int(startframe))

use

            match = search(r"(\d+),(\d+)\.avi$", f)
            if match:
                startframe = match.group(1)
                endframe = match.group(2)
                out = InsertSign(out, join(root, f), int(startframe), int(endframe))
1
  • You're welcome. Please upvote and/or accept my answer if it was useful for you. – MarianD May 21 '20 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.