<p>I found the right property that has to be changed and wrote a function that does the job:</p>

<pre class="lang-js prettyprint-override"><code>function renameComposition(newName) {
    var curComp = null;
    for (var i = 1; i &lt; app.project.numItems +1; i++) {
        if(app.project.item(i) instanceof CompItem) {
            curComp = app.project.item(i);
            curComp.name = newName;
        } 
    }
} 
</code></pre>

CC BY-SA 3.0
2017-01-18T10:03:07.360Z
Beware, though, that this changes teh names of every composition in your project to newName. That does not matter in my case, just fyi.
EluciusFTW
CC BY-SA 3.0
2016-10-11T08:42:11.270Z
2016-10-11T09:12:56.403Z
2016-10-11T09:12:56.403Z
EluciusFTW
<p>I am rendering a project several times, and use a script to change some of the input. However, I have not figured out how to change the name of the output file in the script. </p>

<p>This is basically my script. I left the details of my modifying function out as they are irrelevant.</p>

<pre class="lang-js prettyprint-override"><code>app.beginSuppressDialogs();
{
    var projectFile File("C:\\AfterFX\\MyProject.aep");
    app.open(projectFile);
    MyCustomDataExchangeFunction();
    app.executeCommand(3800);
}
</code></pre>

CC BY-SA 3.0
2016-10-11T07:52:18.293Z
In case anybody is wondering, app.executeCommand(3800) sends the composition to the Adobe media encoder.
EluciusFTW
<after-effects><after-effects-scripting><extendscript>
Change Output file name in AfterFX .jsx script
EluciusFTW
# Change Output file name in AfterFX .jsx script

(Asked by: username_0 on 2016-10-11)

I am rendering a project several times, and use a script to change some of the input. However, I have not figured out how to change the name of the output file in the script. 
This is basically my script. I left the details of my modifying function out as they are irrelevant.
app.beginSuppressDialogs();
{
    var projectFile File("C:\\AfterFX\\MyProject.aep");
    app.open(projectFile);
    MyCustomDataExchangeFunction();
    app.executeCommand(3800);
}

**Tags:** after-effects, after-effects-scripting, extendscript

> **Comments:**
> **username_0**: In case anybody is wondering, app.executeCommand(3800) sends the composition to the Adobe media encoder.  

---

## 1 answers

### Answer by username_0 on 2016-10-11. Score: 2 | Accepted answer

I found the right property that has to be changed and wrote a function that does the job:
function renameComposition(newName) {
    var curComp = null;
    for (var i = 1; i < app.project.numItems +1; i++) {
        if(app.project.item(i) instanceof CompItem) {
            curComp = app.project.item(i);
            curComp.name = newName;
        } 
    }
}

> **Comments:**
> **username_0**: Beware, though, that this changes teh names of every composition in your project to newName. That does not matter in my case, just fyi.  

---

