Skip to main content
Inspiring
October 18, 2019
Answered

Select file dialog for illustrator scripting

  • October 18, 2019
  • 2 replies
  • 4426 views

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?

Correct answer OhmsG

Ok forget all that other stuff!  This worked:  

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

2 replies

CarlosCanto
Community Expert
Community Expert
October 19, 2019

you can use the openDialog Function

 

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

alert(f.fullName);

OhmsGAuthor
Inspiring
October 25, 2019

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

Ten A
Community Expert
Community Expert
October 19, 2019

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

OhmsGAuthor
Inspiring
October 25, 2019

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?