That would be extremely helpful. I really appreciate it, good luck with unpacking!
Ok, I believe I now have something that works. I've tested it a little bit in CC 2014, but have not really put it through the wringer. So use with CAUTION!!!
It may not look pretty, but it works. The only things to be aware of are that it currently does not have a special character verifier to prevent OS folder name issues. The other is that if a duplicate folder name appears within the same parentFolder (see crude example below), it will just not be created in the OS setup. This prevents overwriting folders without warning.
Example:
What is in AE.....
Folder 1
Folder 2
Folder 3
Folder 4
Folder 4 <-----Folder with a duplicate name
Folder 5
Folder 4 <-----Folder with a duplicate name, but is unique to it's parentFolder
What is created in OS.....
Folder 1
Folder 2
Folder 3
Folder 4
Folder 5
Folder 4
Below is the function code, just supply one argument type of a Folder Object. This will be the new root folder to build your AE folder structure in.
var b = Folder.selectDialog("Choose a source folder.");
if(b != null){
aeFoldersToOSFolders(b);
}
function aeFoldersToOSFolders(newRoot){
var proj, allItems, folderCollection, folderCollectionLen, curItem, val, win, userOS, slash, newCorePath, folderNames, folderAEPath, temp;
win = $.os.indexOf("Windows");
win != (-1) ? userOS = "PC" : userOS = "MAC";
userOS == ("PC") ? slash = "\\" : slash = "/";
function getItemParentPath(endItem, ary, slash){
if(endItem == "undefined"){
return ary;
}else if(endItem.name == "Root"){
if(ary.length > 0){
return ary.reverse().join(slash).toString();
}else{
return null;
}
}else{
ary.push(endItem.name);
var newParent = endItem.parentFolder;
return getItemParentPath(newParent, ary, slash);
}
}
proj = app.project;
allItems = proj.numItems;
folderCollection = new Array();
temp = new Array();
newCorePath = decodeURI(newRoot).toString();
for(var i=1; i<=allItems; i++){
curItem = proj.item(i);
if(curItem instanceof FolderItem){
temp.length = 0;
folderAEPath = getItemParentPath(curItem, temp, slash);
if(folderAEPath != null){
folderCollection.push(newCorePath + slash + folderAEPath);
}
}
}
folderCollectionLen = folderCollection.length;
if(folderCollectionLen > 0){
for(var f=0; f<folderCollectionLen; f++){
if(Folder(folderCollection).exists == false){
Folder(folderCollection).create();
}
}
return true;
}else{
return null;
}
}