Quantcast
Viewing all articles
Browse latest Browse all 12845

app.open(); Doubts

Hello guys

 

I wrote a script to open files of a specific folder, simple. Just get some items from a folder and insert it to a listbox, but when there is no one document open in illustrator the script works, and when there is a document open not works.

And I would like open multiple files using the multiselection function of listbox, but not work, only open the first item of selection.

 

I think the problem is in app.open() function, maybe it's not a best way to do this.

This is the script:

var win = new Window('palette', 'Open documents');
win.alignChildren = 'fill';


var folder = Folder.selectDialog ("Select a folder to open your files.");


var list = win.add('listbox', undefined, '', {multiselect: true, numberOfColumns: 1, showHeaders: true, columnTitles: ['Path']});
list.preferredSize = [400, 200];


var btnOpen = win.add('button', undefined, 'Open selected');


var files = folder.getFiles ();


for (i = 0; i < files.length; i++){    var populateList = list.add ('item', files[i]);
};


btnOpen.onClick = function (){
for (i = 0; i < list.selection.length; i++){    var openSel = app.open( new File(list.selection[i]));
//    alert('Testing loop');
};   
};


win.show();

 

I'm very grateful if anyone can help me, please!

 

Thanks in advance, best regards,

-Vinícius


Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>