Skip to main content
Inspiring
Oct 18, 2019 7:29 PM UTC
Answered

Select file dialog for illustrator scripting

I can't find anything related to this in the Illustrator Scripting docs.

I would like to select a file and get a file path so I can do something with it in scripting.  Is this something that should just be done with standard js or does illustrator have a Select File Dialog box you can call?

OhmsGCorrect answer
Inspiring
Oct 25, 2019 10:24 PM UTC

Ok forget all that other stuff!  This worked:  

var result = window.cep.fs.showOpenDialog();
alert(result.data);

8 replies

CarlosCanto
Community Expert
Community Expert
Oct 19, 2019 11:40 PM UTC

you can use the openDialog Function

 

var f = File.openDialog ('Select File...');

alert(f.fullName);

Translate
OhmsGAuthor
Inspiring
Oct 25, 2019 10:17 PM UTC

This did not work, no error just didn't work.

Translate
Ten A
Community Expert
Community Expert
Oct 19, 2019 4:24 AM UTC

If you ExtendScript, You can use "Script UI" class, or you want to make CEP Extension, You can use "showOpenDialog" method under the "window.cep.fs".
However, You need to read some references before you try.
Here are some links you need to know about it.

https://www.adobe.io/apis.html
https://github.com/Adobe-CEP/CEP-Resources/blob/master/CEP_9.x/Documentation/CEP%209.0%20HTML%20Extension%20Cookbook.md

Translate
OhmsGAuthor
Inspiring
Oct 25, 2019 10:17 PM UTC

According to this reference:  

https://www.adobe.com/devnet/creativesuite/articles/adobe-cep-apis.html

 

This would be the code to showOpenDialog:

 var filetypes = new Array(); filetypes[0] = “pptx”; filetypes[1] = “do”; filetypes[2] = “psd”; var result = window.cep.fs.showOpenDialog(false,false,’SELECT PSD’,’/tmp/’,filetypes); alert(result.data); //displays the path to the selected file

 

This does not work.  This however does:

var result = window.cep.fs.readFile(path);  so the window.cep.fs does work but showOpenDialog doesn't. Also I've tried to find more info on showOpenDialog and no luck.  Any ideas what I'm doing wrong?

Translate