How do I extract the name of the footage folder in Finder and pass it to a script?
I have a ScriptUI button that creates a comp of selected SWF files in my AE project panel and applies a few settings to them. You'll see how the comp is named "COMP_v01" but what I need is for the name to be taken from the name of the SWF folder in Finder. For example, the whole path might be "Volumes/Work/Project/MyGreatAnimation/Elephant/" with the 'Elephant' folder containing the SWFs. When I click the button I want the new comp to be named 'Elephant'.
myPanel.grp.group2.swfSetup.onClick = function() {
app.beginUndoGroup("SWF Setup")
var myItems = app.project.selection;
// Create comp
var myComp = app.project.items.addComp("COMP_v01",1920,1080,1,60,24);
// Put comp in the same folder as the selected footage
myComp.parentFolder = myItems[0].parentFolder;
// Create zAssets folder at comp location
var myFolder = app.project.items.addFolder("zAssets");
// Reverse for loop, so that the numerical layer names are listed correctly 00-99
for (var i = myItems.length-1; i >= 0; i--) {
var myItem = myItems[i];
// Add selected footage
myComp.layers.add(myItem);
// Move footage to sub folder
myFolder.parentFolder = myItems[0].parentFolder;
myItems[i].parentFolder = myFolder;
// Scale footage, and collapse tranformation
//myComp.layer(1).transform.scale.setValue([200,200]);
myComp.layer(1).collapseTransformation = true;
}
// Trim comp to duration of footage
myComp.duration = myComp.layer(1).source.duration;
// Deselects all items in the Project window
var selectedItems = app.project.selection;
for (var i = 0; i < selectedItems.length; i++)
selectedItems[i].selected = false;
// Selects the new comp
myComp.selected = true;
// Open comp
myComp.openInViewer();
app.endUndoGroup();
}
For bonus points, I'd love it if the selected SWFs in the AE project panel could first be placed into a project panel folder named 'Elephants', before contiuing with the rest of the script.
I've taken this as far as I can right now, so any help is appreciated. Thanks!
