Copy link to clipboard
Copied
So I've followed along with the tutorials and set a script to replace footage in a template. My question is this, now that the footage has a new name, how do I identify it to get an attribute like duration via script since I won't know it when the script is written?
Original file = TemplateMovie
Replaced file = ABCD5436
Copy link to clipboard
Copied
One easy solution:
Rename the project item of your template manually before running the script. If you replace the file of a project item, Ae only renames the project item, if it has not been renamed manually before.
Example
your file is named "TemplateMovie.mp3" and now the project item automatically also has the name "TemplateMovie.mp4". Now rename the project item to "my template movie", for example.
If you now run an Automation Blocks script which replaces the file by "ABCD5436.mp4" then the project item name will stay "My template movie" and hence, you can still access it with that name.
Solution 2:
If the project item is used in some layer of your project, you can retrieve the project item with the block get attribute "source item" of layer.
In this example, I retrieve the project item of the first layer of the comp with name "my comp":
Copy link to clipboard
Copied
Yet another solution:
You can use the Replace in Text block to update any variable pointing to your project item:
Note that the variable "Project item" contains just a string with a path describing the project item. Hence, you can simply to search & replace like with any other texts, too.
Copy link to clipboard
Copied
The only issue I see with this is that "Template Movie" and "ABCD5436" have to be manually entered in the Automation Blocks interface rather than using a variable.
I'm preferenced to Solution 2 in the prior response, but all these are very helpful as I think they can be used in different cases. Thank you.
Copy link to clipboard
Copied
In the replace text block, you can also use variables instead of hard-coded names.
And if you have a variable containing the full file path, you can use the Tinker File Path block to extract only the file name from it.