Skip to main content
Inspiring
April 28, 2025
Answered

How do you open a file from a default location? Or a file browser?

  • April 28, 2025
  • 1 reply
  • 267 views

Hi all.

 

To work around the lack of any way to set arrowheads on a line programmatically, I need to open a file containing the necessary graphic style or element. The File.openDialog function does indeed raise a file dialog, but so far I haven't seen a way to get default Illustrator locations. Most users will not know where these are.

 

Any insight appreciated.

Correct answer m1b

@Thomas_Calvin  I'm not expert on this question but since no-one else has answered yet I'll add some info. This script snippet shows a possibility. However, I have a suspicion that different Illustrator installations might have different path structures. Perhaps your script could try all the path structures that you know of. Here is one that works on my system (Illustrator 29.5, MacOS 15.4.1).

- Mark

/**
 * Example of providing access to one of the Illustrator presets folders.
 * 
 * There may be better ways to do this, and I suspect that
 * this may not work on all versions and OSes.
 * 
 * @author m1b
 * @version 2025-04-29
 * @discussion https://community.adobe.com/t5/illustrator-discussions/how-do-you-open-a-file-from-a-default-location-or-a-file-browser/m-p/15293796
 */
(function () {

    // this *might* be the path to the Presets folder
    var presetsFolder = Folder(app.path + '/Presets.localized/' + app.locale);

    if (!presetsFolder.exists)
        return alert('Could not determine presets folder at "' + decodeURI(presetsFolder) + '".');

    // ask use to choose a symbol libary document
    var f = File.openDialog('Choose a symbol library', presetsFolder + '/Symbols');

    if (f)
        app.open(f);

})();

1 reply

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
April 29, 2025

@Thomas_Calvin  I'm not expert on this question but since no-one else has answered yet I'll add some info. This script snippet shows a possibility. However, I have a suspicion that different Illustrator installations might have different path structures. Perhaps your script could try all the path structures that you know of. Here is one that works on my system (Illustrator 29.5, MacOS 15.4.1).

- Mark

/**
 * Example of providing access to one of the Illustrator presets folders.
 * 
 * There may be better ways to do this, and I suspect that
 * this may not work on all versions and OSes.
 * 
 * @author m1b
 * @version 2025-04-29
 * @discussion https://community.adobe.com/t5/illustrator-discussions/how-do-you-open-a-file-from-a-default-location-or-a-file-browser/m-p/15293796
 */
(function () {

    // this *might* be the path to the Presets folder
    var presetsFolder = Folder(app.path + '/Presets.localized/' + app.locale);

    if (!presetsFolder.exists)
        return alert('Could not determine presets folder at "' + decodeURI(presetsFolder) + '".');

    // ask use to choose a symbol libary document
    var f = File.openDialog('Choose a symbol library', presetsFolder + '/Symbols');

    if (f)
        app.open(f);

})();
Inspiring
April 29, 2025

Thanks! I will probably start with this, and then save whatever path the user navigates to.