Skip to main content
Inspiring
March 16, 2012
Answered

How do you use JS to open a Folder dialog

  • March 16, 2012
  • 1 reply
  • 32654 views

If you use this to open a dialog box to select a file:

     File.openDialog("Select your XML File", "*.xml")

The how do you open a dialog to select a folder.  I would think it would be something like

     Folder.openDialog

but alas, it is not, and I cannot find any reference on how to do it anywhere.  Does any one know?

Thanks

This topic has been closed for replies.
Correct answer BigGunN

I found it after I posted this.  It was answered in this thread

but if you dont want to look there, this is the long and short of it...

it is not opendialog.   it is openDlg  (how intuitive is that)

var myDefault = new Folder ("U:/xxx/zzz");

var myFiles = myDefault.openDlg(prompt string, filter string+pattern, multi-selection bollean);

1 reply

BigGunNAuthorCorrect answer
Inspiring
March 16, 2012

I found it after I posted this.  It was answered in this thread

but if you dont want to look there, this is the long and short of it...

it is not opendialog.   it is openDlg  (how intuitive is that)

var myDefault = new Folder ("U:/xxx/zzz");

var myFiles = myDefault.openDlg(prompt string, filter string+pattern, multi-selection bollean);

Jongware
Adobe Expert
March 16, 2012

I'm confused. That last one does not let you select a folder, it lets you select a file? 'Cause you initially asked

BigGunN wrote:

The how do you open a dialog to select a folder.

To select a folder, you can use either Folder.selectDialog or (folder object).selectDlg. There are a few (pretty vaguely described ) differences, but in general I don't care and use one of these:

// Generic form

f = Folder.selectDialog("wot");

alert (f);

// Pre-selected starting point

folder = new Folder("/usr/bin");

f = folder.selectDlg("wot");

alert (f);

// Pre-defined starting point

folder = Folder.myDocuments;

f = folder.selectDlg("wot");

alert (f);

The full description of the Folder object can be found in the ESTK's Object Model Viewer (it's under Help; then select "Javascript Base Classes" in the ugly help browser that pops up); and also in my version of the same data, available online at http://jongware.mit.edu/idcs5js/pc_Folder.html (which is in the CS5 version, but I don't think something changed in the Base Classes).

BigGunNAuthor
Inspiring
March 16, 2012

But I tried the method I posted and it does let me select a folder.  I haven't tried your method yet, although I am sure that they work as well since you haven't failed me yet.

But I can verify that what I posted does work in allowing me to select a folder from a dialog.

I actually have your CHM file open already, although I am working on trying to understand the Script UI stuff at the moment.

Thanks,