Script AE Dropdownlist array of a folder issue

New Here ,
Sep 16, 2020

Copy link to clipboard

Copied

hello, i'm trying to make a list of all files inside my main folder and put it inside a dropdownlist.

but i don't now why is not working.

I have a result NaN instead of a list with my files

here is my code ,thanks a lot


// list of all files inside MyFolder
var MyFolder = Folder("/R/MyFolder/");
var arrayPresets = MyFolder.getFiles('');
var fileNames = getFileNames(arrayPresets);
function getFileNames(arrayPresets) {
var fileNames = [],
baseName = "";
for (var i = 0, il = arrayPresets.length; i < il; i++) {
baseName = arrayPresets[i].displayName.split(".")[0];
fileNames.push(baseName);
}
return fileNames;
}

//====================UI=======================================
//=============================================================
function myScript(thisObj){
function myScript_buildUI(thisObj){
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "test", [300, 300, 300, 300], {resizeable:true});

res = "group{orientation:'column', alignment:['left', 'top'], alignChildren:['fill', 'fill'],\
myTabSettings: Panel{type:'tabbedpanel',text:'',\
myPanelList: Panel{type:'tab',text:'Test', orientation:'column',alignChildren:['fill', 'fill'],\
groupOneButtons: Group {text:'', orientation:'row',alignChildren:['center', 'center'],\
TextButton: StaticText{text:'Folders:', preferredSize:[43,25]},\
ListButton: DropDownList{properties:{items:[fileNames]}, preferredSize:[170,25]},\
},\
},\
},\
}";
//Add resource string to panel
myPanel.grp = myPanel.add(res);

//add my folder array to my list ??
myPanel.grp.myTabSettings.myPanelList.groupOneButtons.ListButton.properties.items=fileNames.toString()
alert(fileNames.toString())
//~ myPanel.grp.myTabSettings.myPanelList.groupOneButtons.ListButton.text=" + fileNames.toString() + "


//====================SHOW==UI================================

//Setup panel sizing and make panel resizable
myPanel.layout.layout(true);
return myPanel;
}
var myScriptPal = myScript_buildUI(thisObj);
if (myScriptPal != null && myScriptPal instanceof Window){
myScriptPal.center();
myScriptPal.show();
}
}
myScript(this);

 

TOPICS
Scripting

Views

49

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Guide ,
Sep 16, 2020

Copy link to clipboard

Copied

This looks odd:

 

for (var i = 0, il = arrayPresets.length; i < il; i++)

 

 

Try:

 

for (i = 0; i < arrayPresets.length; i++)

 

*Martin

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more