Extracting data from filename (help me optimize this small chunk of code)

Rather than using some fancy msp ways to detect the bpm of some of my loops, I chose to include the exact bpm in the filename and now I am extracting it when I load the file to my buffer. However, I am wondering if there’s a way to do it with less objects.

I know the bpm is written in the 5th, 6th and 7th character from the right, so after converting my filename into a list, I revert it and select these 3 characters. If the filename has no bpm, these characters won’t be number so in the end I get 0, I will make sure receiving a 0 there will turn off the bpm sync.

So yeah, I think this patch works fine but I am wondering if I could make it shorter / more efficient.

Thanks.

– Pasted Max Patch, click to expand. –

Copy all of the following text. Then, in Max, select New From Clipboard.