-
Loop through project panel and select comp
I am new to scripting and I would love some help and advice!
I have a template project that requires me to constantly replace the image in my comp. Using Replace Footage is tedious as I constantly have to navigate folders.
I have created a script that opens a dialog window pointing to a specific folder, and when I import my new image it automatically replaces the one currently in the comp. The problem is the comp index sometimes changes due to the image filenames being different, causing my script to fail.
Please could someone help me change the first line of code so that it loops through the project panel and automatically selects the comp?
// access the comp
var theComp = app.project.item(2);// get the existing image layer in the comp
var theImageObject = theComp.layers[2];// bring up folder to import the new image that I'd like to use
var newArtwork = new Folder("C:/Users/PC/Pictures").openDlg("Import File");// import new image
var newImport = app.project.importFile (new ImportOptions (newArtwork));// replace the existing image with the new one
theImageObject.replaceSource(newImport, true);