Can scripting make a new AE folder?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
everydayme
Posts: 4
Joined: August 13th, 2008, 9:33 pm

Hi all,

I have been scouring internet and forums, to try and find a scripting command to make a new AE folder. Not a windows folder. We are needing to write a script similar to smartimport, that will additionally put the sequences in their own folders, and name the folder according to the parent folder name the sequences were in.

Is this even possible. Heaps of ref for making windows dirs, but nothing for new AE folders.

TIA everyone
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

From page 79 of the Scripting Guide:


ItemCollection addFolder() method
app.project.itemCollection.addFolder(name)

Description
Creates a new folder. Creates and returns a new FolderItem object and adds it to this collection.
JavaScript Reference ItemCollection object
If the ItemCollection belongs to the project or the root folder, then the new folder’s parentFolder is the root
folder. If the ItemCollection belongs to any other folder, the new folder’s parentFolder is that FolderItem.
To put items in the folder, set the item object’s parentFolder attribute; see “Item parentFolder attribute” on
page77.

Example
This script creates a new FolderItem in the Project panel and moves compositions into it.
// create a new FolderItem in project, with name “comps”
var compFolder = app.project.items.addFolder(“comps”);
// move all compositions into new folder by setting
// compItem’s parentFolder to “comps” folder
for(var i = 1; i <= app.project.numItems; i++) {
if(app.project.item(i) instanceof CompItem)
app.project.item(i).parentFolder = compFolder;
}
name A string containing the name of the folder.
DaveMcD
Posts: 7
Joined: May 9th, 2007, 8:48 pm
Contact:

just a quick note. I've been working through this example and the code is a bit wrong.
Because you move the items into the folder as you go you change the positions of each item in the project as they are moved. So in effect it skips every second comp leaving ti where it was. Just through it might come in handy for other to know the example is broken.

DaveMcD
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Yeah, this came up on the AE-List. A solution is to do 2 loops, first you move all the comps into an array and then you move those comps into the folder:

Code: Select all

// create a new FolderItem in project, with name "comps"
var compFolder = app.project.items.addFolder("comps");
// move all compositions into new folder by setting
// compItem's parentFolder to "comps" folder
var myComps = new Array();
for(var i = 1; i <= app.project.numItems; i++) {
if(app.project.item(i) instanceof CompItem)
 myComps[i-1] = app.project.item(i);
}

for (j=0; j<=myComps.length-1; j++){
myComps[j].parentFolder = compFolder;
}
_lloyd
Post Reply