Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Select file dialog for illustrator scripting

Contributor ,
Oct 18, 2019 Oct 18, 2019

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?

TOPICS
Scripting
3.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Oct 18, 2019 Oct 18, 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%20Exte...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 25, 2019 Oct 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 25, 2019 Oct 25, 2019

The documentation has read file from path, make dir, writeFile but no showOpenDialog or how to select a file:

https://github.com/Adobe-CEP/CEP-Resources/blob/master/CEP_9.x/Documentation/CEP%209.0%20HTML%20Exte...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 25, 2019 Oct 25, 2019

Ok forget all that other stuff!  This worked:  

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2019 Oct 19, 2019

you can use the openDialog Function

 

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

alert(f.fullName);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 25, 2019 Oct 25, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 19, 2019 Dec 19, 2019

Can i filter pdf file?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 28, 2025 Apr 28, 2025
LATEST

I was shocked to find that this actually works. Now... how do we find the path of the scripts directory?

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