ulikilian wrote:
A helpful thing (and probably quite easy to write) would be a script which duplicates the current comp and replaces all footage ending with "_L" with footage which ends with "_R" (oups... sound strange... did you get that? What I mean: just replace "tralala_L.jpg" with "tralala_R.jpg" in the duplicated comp - that's all).
Any help would be much appreciated.
Thanks!
Uli
Try this. It expects that the matching _R footage has been imported into the project.
Code:
{
// this script duplicates the currently selected comp and replaces any footage
// thats name contains "_L" with matching footage containg "_R"
var charIndex, newName;
var activeItem = app.project.activeItem;
// make sure a comp is selected
if (activeItem != null && activeItem instanceof CompItem) {
// duplicate the comp
var newComp = activeItem.duplicate();
// loop through layers in dupe comp, looking for footage source that contains "_L"
for (var x=1; x <= newComp.layers.length; x++) {
if (newComp.layer(x).source.name.indexOf("_L") != -1) {
// work out name for "_R" footage
charIndex = newComp.layer(x).source.name.indexOf("_L")
newName = newComp.layer(x).source.name.substring(0,charIndex);
newName += "_R";
newName += newComp.layer(x).source.name.substring(charIndex+2, newComp.layer(x).source.name.length);
// loop through all project items looking for matching footage names
for (y = 1; y <= app.project.items.length; y++) {
// replace the layer
if (app.project.item(y).name == newName && app.project.item(y) instanceof FootageItem) {
newComp.layer(x).replaceSource(app.project.item(y), true);
}
}
}
}
}
}