Skip to main content
Inspiring
April 29, 2020
Question

How to select a directory (folder) using window.cep

  • April 29, 2020
  • 2 replies
  • 2090 views

Reading a file with cep from my js file looks like this:

 

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

 

Is there away where I can select a directory?  The above only selects a file.

Meaning I'd like illustrator to prompt me to select a folder.  After I select it in Illustrator then I could save the path.

This topic has been closed for replies.

2 replies

Justin Taylor-Hyper Brew
Community Expert
Community Expert
March 30, 2022

You can find defs for the cep.fs functions in CEP Engine Extensions

   /**
     * Displays the OS File Open dialog, allowing the user to select files or directories.
     *
     * @9397041 allowMultipleSelection {boolean} When true, multiple files/folders can be selected.
     * @9397041 chooseDirectory {boolean} When true, only folders can be selected. When false, only
     *        files can be selected.
     * @9397041 title {string} Title of the open dialog.
     * @9397041 initialPath {string} Initial path to display in the dialog. Pass NULL or "" to
     *        display the last path chosen.
     * @9397041 fileTypes {Array.<string>} The file extensions (without the dot) for the types
     *      of files that can be selected. Ignored when chooseDirectory=true.
     *
     * @Return An object with these properties:
     *      <ul><li>"data": An array of the full names of the selected files.</li>
     *          <li>"err": The status of the operation, one of
     *          <br>NO_ERROR
     *          <br>ERR_INVALID_PARAMS </li>
     *      </ul>
     **/
    cep.fs.showOpenDialog(allowMultipleSelection, chooseDirectory, title, initialPath, fileTypes)
Ten A
Community Expert
Community Expert
April 29, 2020

To set 2nd argument to true like below.

var result = window.cep.fs.showOpenDialog(false, true, "Select folder...");
if (result.err==0) [
console.log(result.data);
}
else {
console.log(result.err);
}