Copy link to clipboard
Copied
Hello everyone,
How Can I apply a script .jsx on multiple compositions at once? I do have several compositions within a project but finding them and applying the same script it's time consuming. Is there any way to do it at once or a work-around? Thank You.
This would be one way to loop through all comps and combine your two functions:
var myComp, myLayer, myTextLayer, myAudioLayer;
for (var i = 1; i <= app.project.numItems; i++){
myComp = app.project.item(i);
if (! (myComp instanceof CompItem)) continue;
for (var j = 1; j <= myComp.numLayers; j++){
myLayer = myComp.layer(j);
if (myLayer.hasAudio){
myLayer.outPoint = myLayer.inPoint + myLayer.source.duration;
}
}
for (var j = 1; j <= myComp.numLayers; j++){
myTextLayer = myComp.laye
...
Copy link to clipboard
Copied
That functionality can be built into the script itself by letting it comb through all project items, but without knowing what script you use and what you expect it to do nobody can tel lyou much. As always the devil's in teh details.
Mylenium
Copy link to clipboard
Copied
So I'm using two sctipts. One of them is this one:
var myComp = app.project.activeItem;
var myLayer;
for (var i = 1; i <= myComp.numLayers; i++){
myLayer = myComp.layer(i);
if (! myLayer.hasAudio) continue;
myLayer.outPoint = myLayer.inPoint + myLayer.source.duration;
}
and the second:
function adjustText(){
var myComp = app.project.activeItem;
if (myComp == null || ! (myComp instanceof CompItem)){
alert ("No comp active.");
return;
}
var myTextLayer;
var myAudioLayer;
for (var i = 1; i <= myComp.numLayers; i++){
if (myComp.layer(i) instanceof TextLayer){
myTextLayer = myComp.layer(i);
try{
myAudioLayer = myComp.layer(myTextLayer.name + ".mp3");
}catch (err){
myAudioLayer = null;
}
if (myAudioLayer == null) continue;
myTextLayer.startTime = myAudioLayer.inPoint;
myTextLayer.outPoint = myAudioLayer.outPoint;
}
}
}
adjustText();
Do you got any advice how to make it happen? Or where should I start looking for this solution? Thank you.
Copy link to clipboard
Copied
In a nutshell, instead of
var myComp = app.project.activeItem;
you need to put your code inside a loop which iterates over all compositions, and then assign myComp to a different comp in each iteration.
There is no direct way to access the list of all compositions in the scripting API. Instead, you need to loop over all project items and then check for all of them, if they are compositions.
Note that my extension Automation Blocks allows to create scripts in a simpler, visual way. There you would use the "for each project item" block to loop over all comps and the simply plug and code blocks inside of it, which should be executed for all these comps.
Copy link to clipboard
Copied
The respecetive loop is part of pretty much any script that does project-wide changes, so you can just snatch it from an existing script and adjust your variables. A short excursion to AEScripts.com and downloading one of those bulk composition chnaging tools can show you how it's done You basically define a variable with myItems=app.project.items and then do a for(i=0;i>=myItems.length;i++) loop and then check each active item. This can be super fancy with item type checks or just quick & dirty.
Mylenium
Copy link to clipboard
Copied
is there any other free solution? or at least a tutorial to get close to the solution?
Copy link to clipboard
Copied
This would be one way to loop through all comps and combine your two functions:
var myComp, myLayer, myTextLayer, myAudioLayer;
for (var i = 1; i <= app.project.numItems; i++){
myComp = app.project.item(i);
if (! (myComp instanceof CompItem)) continue;
for (var j = 1; j <= myComp.numLayers; j++){
myLayer = myComp.layer(j);
if (myLayer.hasAudio){
myLayer.outPoint = myLayer.inPoint + myLayer.source.duration;
}
}
for (var j = 1; j <= myComp.numLayers; j++){
myTextLayer = myComp.layer(j);
if (myTextLayer instanceof TextLayer){
try{
myAudioLayer = myComp.layer(myTextLayer.name + ".mp3");
}catch (err){
myAudioLayer = null;
}
if (myAudioLayer == null) continue;
myTextLayer.startTime = myAudioLayer.inPoint;
myTextLayer.outPoint = myAudioLayer.outPoint;
}
}
}
Copy link to clipboard
Copied
Thank you so much Dan Ebberts,
This one works like a charm! Exactly What I needed 🙂
Copy link to clipboard
Copied
Register on AEScripts.com, add some free scripts like Rd Comp Setter or the Nab scripts, copy & paste their functions. For copyright reasons we can't just provide the code here.
Mylenium
Copy link to clipboard
Copied
Thank you 🙂
I guess sth like this could help as well, but i'm still exploring the aescrips.com website
function openComps() { var comps = []; do { comps.unshift(app.project.activeItem); app.executeCommand(app.findMenuCommandId("Close")); } while (app.project.activeItem != null && app.project.activeItem instanceof CompItem); for (var i = 0; i < comps.length; i++) { comps[i].openInViewer(); } return comps }