Skip to main content
Inspiring
November 12, 2020
Question

Can a script rename footage in the Project window and also in Finder without breaking links?

  • November 12, 2020
  • 1 reply
  • 1380 views

I'm using the brand new Timelord extension which easily imports multiple Animate SWF layers directly into AE.

 

The trouble is, the exported SWFs are simply named after the layer in Animate. This makes sense for most users. However, for our specific workflow I need to prefix the names with the name of the FLA file they came from. So the new worklow involves exporting the layers from Animate using Timelord, they are then automatically copied in to AE, I then need to rename them in the Finder, and then manually re-link each file in AE. Not ideal!

 

I would want to select multiple SWF files in the project window, then hit a Script UI button that asks me what prefix I want to use, which I would then type in. That name would then also get automatically written to the file in Finder without breaking the AE projects link to that file. Is this possible?

This topic has been closed for replies.

1 reply

Inspiring
November 13, 2020

This is how far I've got up to now…

 

// Get selected item
var myItem = app.project.activeItem;

// This is the new name
var myNewName = "new_name.swf";

// Rename Footage
myItem.name = myNewName;

// Rename File
myItem.file.rename(myNewName);

// Replace footage
var myPath = "~/Desktop/TEST/"+myNewName;
myItem.replace(File(myPath));

 

 
I just need to figure out how to change it from a hard coded variable to something that prompts the user for a name instead. And I guess also something which uses the current SWF folder and not a test folder on the desktop. hmm.

 

Inspiring
November 13, 2020

Or should I say… something that prompts the user for a *prefix* to the current name

Inspiring
November 13, 2020

I've made a little more progress. The user is now prompted for a prefix.

var myItem = app.project.activeItem;
var oldName = myItem.name.substring(0, myItem.name.lastIndexOf("."));
var spacer = " - "
var fileExt = ".swf"

// Prompt for prefix
var myNewName = prompt('Enter a prefix', oldName);

// Assemble new footage name
myItem.name = myNewName+spacer+oldName+fileExt;

// Assemble new file name
myItem.file.rename(myNewName+spacer+oldName+fileExt);

// Replace missing footage
var myPath = "~/Desktop/TEST/"+myNewName+spacer+oldName+fileExt;
myItem.replace(File(myPath));

 

All I need to solve now is to (1) make it work with multiple files at once, and (2) change the hard coded myPath to instead be the current path the footage was/is located. I'm stuck though, so any help would be appreciated!