Change compositions names with text from external file
i have a new project which helps me render dozens of clips. The simplified version of it can be found in the attached file. I have only put 3 compositions in it for example, but my project can have up to 100 compositions. Dovnload here my project file
The project reads some texts from a .txt file for the text layers that i have using expressions, and simplify a lot my work.
The .txt file is located on Desktop and look like this:
var Text1 = ["The First Text"];
var Text2 = ["The Second Text"];
var Text3 = ["The Third Text"];
var Clip1 = ["This Is The First Text Video"];
var Clip2 = ["This Is The Second Text Video"];
var Clip3 = ["This Is The Third Text Video"];
Can anybody help me with a script that automatically changes "Clip1" "Clip2" and "Clip3" compositions name withe the corresponding text found on the .txt file please?
Thanks in advance!
Anyway, if you structure your text file with a 'split' character, which differentiates the comp name from the text to change, you can have your script extract 2 pieces of data from that single line. I've created a test text file which does this, following the 'Comp Name/Text Content' format. Keep in mind, that I am using the "/" character here to split, so this won't work if your text or comp name has a slash in it.
Text file looks like this:
And we can use a script to split each of those lines. The script then finds a comp that has the same name as the pre-/ part of the line, and changes it's text layer's text to be the post-/ part.
Disclaimer: this was written for only testing purposes. It does not have fallbacks for if you have 2 comps named the same thing or if it can't find a comp. It also assumes each comp has only 1 layer and that layer is a text layer. With a few tweaks, though, you should be able to make it work in a production environment.
Best of luck!
Also, giving credit where credit is due: the majority of this code is lifted directly from Dan's fantastic case study on reading an external text file on motion script. I'd highly recommend checking it out as he is more thorough than I have been here.
Thank you for helping me.
I need a script to change the names of the compositions....for example:
The composition "Clip1" becomes "The First Video Title"
The composition "Clip2" becomes "The Second Video Title"
The composition "Clip3" becomes "The Third Video Title"
so let's forget about parsing text fron external file for now, can you help me with a script that simply do this: give to those compositions from the progect new names?
Thank you in advance
Hey there, sorry for misunderstanding.
A quick change on line 28 should do what you want (with also reading from the same slash-split external file).
In general, if you want to rename some project items, you can do it like this:
You basically loop through all the project items until you find one that has the same name as the 'searchName' var, then change that item's name to the value of newName.
Here's the updated script, which should now change the name of the comp, rather than the text layer inside of the comp:
My text file (still) looks like this:
Thanks a lot, it works!