Copy link to clipboard
Copied
Hello all,
I could use a little help, maybe you can help me?
I have on a layer "LayerX" text fields in a group with certain name "TextX".
There are several groups on the layer with the same text fields and I want to apply my script to all text fields in the document with the name "TextX".
but unfortunately i can't get the loop to run it only selects the 1st "TextX" on the layer "LayerX" and then the script stops.
try{
var myDoc = app.documents[0];
var myLoop = myDoc.allPageItems;
for(var i = 0; i < myLoop.length; i++){
var doc = app.documents[0];
app.select(NothingEnum.NOTHING);
doc.layers.itemByName("LayerX").pageItems.itemByName("TestX").select(SelectionOptions.ADD_TO);
var myStory = app.selection[0].parentStory;
var myOversetEnd = myStory.characters.length-1;
var myOverset = myStory.characters.itemByRange(4, myOversetEnd);
myOverset.remove();}
}catch(e){alert("Something gone wrong!" + e);};
itemByName only finds the first instance of a given object, even if multiple objects have the same name. Instead you have to loop through all page items and check each name, then act. Also simplified your code a bit below.
try{
var myDoc = app.documents[0];
var myLoop = myDoc.allPageItems;
for(var i = 0; i < myLoop.length; i++){
if (myLoop[i].itemLayer.name == "LayerX" && myLoop[i].name == "TestX") {
var myStory = myLoop[i].parentStory;
myStory.characters...
Copy link to clipboard
Copied
itemByName only finds the first instance of a given object, even if multiple objects have the same name. Instead you have to loop through all page items and check each name, then act. Also simplified your code a bit below.
try{
var myDoc = app.documents[0];
var myLoop = myDoc.allPageItems;
for(var i = 0; i < myLoop.length; i++){
if (myLoop[i].itemLayer.name == "LayerX" && myLoop[i].name == "TestX") {
var myStory = myLoop[i].parentStory;
myStory.characters.itemByRange(4, -1).remove();
}
}catch(e){alert("Something gone wrong!" + e);};
Copy link to clipboard
Copied
Vielen Dank brianp311 !
Das hilft mir wirklich sehr 👍
Copy link to clipboard
Copied
Hello @brian_p_dts , do you know much about scripting in Premiere Pro? I would have some questions if possible.
Copy link to clipboard
Copied
The Premiere Pro forum, that's the place to go.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more