-
SCRIPTING: strip framenumbers from sequence filename…
Hi,
As promised I’m back for more 😉 And this time I think I’ve got a more complicated question.
So I’ve got this script automatically creating comps from footage items, and adding them to the Render Que automatically. Working well so far.
But… since the source files are also image sequences they show up in the Project Window like this: sequencename_[0000-9999].dpx
When you manually create a comp from footage AE understands to reduce the comp name to ‘sequencename’. But when I use a script to set the name of the comp to the item name of course I get the whole item name.
I can do something with .substring(0,n), to take only the first part of the name, if the length of the ‘meaningful’ part is consistent. But it’s not of course. So I guess what I need to do is remove anything between brackets and the extension (the latter is easy-ish by getting the .length and substracting 4 and putting that into the substring.
(I’m actually pretty shocked that this makes sense to me…)
The code below is what I use to create the comp from the item.
var myComp = app.project.items.addComp(selectedItems[i].name, selectedItems[i].width, selectedItems[i].height, selectedItems[i].pixelAspect , selectedItems[i].duration, selectedItems[i].frameRate);
So… what would be the most elegant way to create a comp name without the framenumbers and extension?
For bonus points: sometimes there is a ‘.’ to separate filename from framenumbers, sometimes there’s an ‘_’ and sometimes there’s nothing. Ideally I’d strip the extension, the framenumbers AND if there’s an underscore or period stip also…
I’m guessing there’s no way to just use the built-in mechanism in AE through a script?
Barend