Thank you so much for this, spk77 and cfillion! It's been a staple in my workflow for about a year at this point. However, it seems to refuse to split the media item even if it is not locked but it is "locked to the active take". I don't know if this behavior was intended, but it isn't suitable for my own workflow, at least.
I've gone ahead and tried to solve this myself, but I haven't found a great way to solve it yet, since it seems like "C_LOCK" returns a 1 if anything regarding the media item at all is locked. So I've made a version that will *always* split the item if it has multiple takes. It is a very hacky solution, but it works. If you know of a better way to solve this, I'd love to hear about it!
By the way, is there a good way to get this version on ReaPack? This is my first time doing anything with Reaper scripting, so I don't know how ya'll work your magic quite yet