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

Participant ,
Apr 29, 2020 Apr 29, 2020

Copy link to clipboard

Copied

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.

TOPICS
Scripting

Views

792

Likes

Translate

Translate

Report

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 Professional ,
Apr 29, 2020 Apr 29, 2020

Copy link to clipboard

Copied

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);
}

 

Likes

Translate

Translate

Report

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 Professional ,
Mar 30, 2022 Mar 30, 2022

Copy link to clipboard

Copied

LATEST

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.
     *
     * @Param allowMultipleSelection {boolean} When true, multiple files/folders can be selected.
     * @Param chooseDirectory {boolean} When true, only folders can be selected. When false, only
     *        files can be selected.
     * @Param title {string} Title of the open dialog.
     * @Param initialPath {string} Initial path to display in the dialog. Pass NULL or "" to
     *        display the last path chosen.
     * @Param 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)

Likes

Translate

Translate

Report

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