Select / Find a file in Project Panel by Word
I'm trying to write a script but I'm newbie and it's not working.
I have a bunch of files from different sources. The only thing in common between them are some words in the name, for example FullHD.
What I need is select all the files with the word FullHD in the project panel, and then create a comp with each one.
Can you help me??
Here's an example of how to do something like this.
The main method you'll be using here is "indexOf()", which basically checks if a string contains another string, and returns where in the string that new string is. For instance, "MyComp_FullHD".indexOf("FullHD") will return 7. The nice part of indexOf() is that it returns -1 if it can't find your string. For instance "MyComp".indexOf("FullHD") will return -1, since it doesn't appear in the string. This is what I'm doing on Ln 31 and is what's filtering your comp items.
The only other tricky part is that making a composition requires 6 parameters (name, width, height, PAR, duration and frame rate). Since certain project items (like a still, or audio) don't have all of these parameters, you need to supply the .addComp() method with fallbacks to handle these situations.
This is what the 'defaults' object on line 6 does. In case the source file you're using doesn't have a frame rate, for example, the script will use defaults.frameRate instead. You can do this by supplying your ideal argument, then an || (or), followed by your default.
Other than that, just change the function call on ln 55 to to use your preferred text filter. Keep in mind, it's case sensitive!