Skip to main content
Inspiring
January 14, 2025
Question

ScriptUI renaming Render Queue items - names are truncated after period. How to solve?

  • January 14, 2025
  • 0 replies
  • 86 views

After Effects 25.1.0

Windows 11

 

Short version - using a script to set output file names for items in the Render Queue causes any output names from comps that have periods in their names to be truncated from the period on.

 

I've written a scriptUI panel that adds selected items from the Project panel to the Render Queue. It takes the comp name as the base of the output file name, and has options to prepend and append user-defined strings to the file name (stuff like version number, date etc). It also generates a drop-down with all the output templates so the user can select a template and apply it to all the items being added. It also can set a folder to save the output in.

 

To programatically set any folder other than whatever it defaults to when simply adding an item to the Render Queue, you have to create a new File object and specify the path and filename.

 

My problem is that any comp that has a period anywhere in the original comp name will have everything in the name after (and including) the period deleted when the name is updated in the Render Queue item. Same if I programatically add a period to the name.

 

For example, there's a comp called "Smoke Explosion 5.mov Comp 1". Even if I pass that comp name directly to the string specifying the new File, once the script finishes, the file name in the Render Queue will be "Smoke Explosion 5.mp4". Any text the script appends to the file name is also gone.

 

I put an "alert()" in the script after the line where I create the File object, like this:

 

var myFile = new File(comboPath);
alert(myFile.displayName);

 

where comboPath is the string concatenating the folder location with the filename. I stripped the code back so comboPath is only holding the name of the comp, pulled from the compItem object from the itemCollection. The "alert" shows the entire comp name (in the example above, the alert box would show "Smoke Explosion 5.mov Comp 1" but the Rendere Queue item only shows "Smoke Explosion 5.mp4".

 

So there doesn't seem to be anywhere I can intercept whatever is happening that truncates the name.

 

The really frustrating thing is that if I add the comp to the Render Queue without renaming it, it has the full, untruncated name.

 

I thought After Effects might somehow be detecting file extensions and over-eagerly trimming them to avoid duplication, but it happens even if I randomly stick a period in a comp name where none of the following text after the period could be confused with a file extension.

 

I tried escaping the period in the comp name before I pass it to the new File constructor, like this:

 

if (myItem.name.indexOf(".") != -1) {
      var regex = /\./g;
      fileBaseName = myItem.name.replace(regex, '\.');
      }

 

which did not have any effect. I then added another backslash to the replacement string to escape the other backslash like this:

if (myItem.name.indexOf(".") != -1) {
      var regex = /\./g;
      fileBaseName = myItem.name.replace(regex, '\\.');
      }

 

and that resulted in the filename in the Render Queue item being "_mov Comp 1.mp4"

 

?!?

 

Has anyone else experienced this? Is there any way to work around this? I really want to preserve the full comp names as the basis of the new output file names, while having the ability to modify the names with user input.

 

I guess I could replace periods with some (hopefully) unique string, then use a bulk renamer in a file explorer window to put the periods back in, but i'd obviously prefer not to.

 

Please help!