0

I'm trying to get the name of a composition and change it to something else. I know that it is possible when I select the comp (active), but I would like to do it automatically.

Sample: In a project (name = eps111_sc222_v02.aep) I have a dozen comps, the one I would like to change is named "eps111_sc222_V01".

Now I would like to search for all comps in my project that include "_V". Basically like this:

// get new name from project, project name

var currentFile = app.project.file.name;
currentFile = curFile.substring(0,curFile.length-4);


for (var i = 1; i <= app.project.numItems; i++)
{

 if((app.project.item(i)instanceof CompItem) 
&& (app.project.item(i).name === "_V"))

{

 app.project.item(i).name == currentFile;

    }
}  

So, the comp should get the name of the project. Is that possible?

I tries this also:

var string=app.project.item(i).name;
 expr = "/_V/";
string.search(expr);

but I think my problem is: how do I get the values here...?

Dieter
  • 1
  • 2

1 Answers1

0

Solution:

var currentFile = app.project.file.name;
currentFile = currentFile.substring(0,currentFile.length-4);

for (var i=1; i<=app.project.numItems; i++){

    if ((app.project.item(i) instanceof CompItem) && (new RegExp(/_V/).test(app.project.item(i).name)))
    {
    new RegExp(/_V/).test(app.project.item(i).name= currentFile);
    }
}

This changes the composition with a "_V" in it's name to the current project name. If it helps somebody - take it. If there are better suggestions, it would be nice to see them.

Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
Dieter
  • 1
  • 2