2 Replies Latest reply on Apr 9, 2015 7:22 PM by xbytor2

    Folder browsing dialog always returns the application's folder, not the one I selected

    matb25746895

      My script uses a hard-coded destination path to save files. I want to make it more flexible with a file browsing dialog.

       

      The selectDlg folder function seems obvious, but it always returns Photoshop's folder location, not the folder I chose in the dialog.

       

      For example:

      var outputFolder = Folder();

      outputFolder.selectDlg("Output folder:");

      $.write(outputFolder);

       

      Expected:

      My JavaScript console should report the folder that I selected in the system dialog.

       

      Actual results:

      No matter which folder I select in the dialog, it always returns as:

      /c/Program%20Files/Adobe/Adobe%20Photoshop%20CC%202014/tmp00000001

       

      The directory path is where Photoshop is installed on my computer. The tmp00000001 folder seems to be generated.

       

      Am I missing something obvious?

        • 1. Re: Folder browsing dialog always returns the application's folder, not the one I selected
          JJMack Most Valuable Participant

          I modified some script I found  dialog to suit my needs its dialog had an input and output folder fields the could be set by navigating to the and selecting then.  Using on clock buttons.  The dialog fields looked something like this....

           

          // Add a panel to hold title and 'message text' strings

           

           

          dlg.msgPn2 = dlg.add('panel', undefined, 'Input Folder');

          dlg.msgPn2.orientation = "column";

          dlg.msgPn2.alignChildren = 'Right';

           

           

          dlg.msgPn2.InputFolder = dlg.msgPn2.add('group');

          dlg.msgPn2.InputFolder.orientation = "row";

          dlg.msgPn2.etInputFolder = dlg.msgPn2.add("edittext", undefined, exportInfo.destination.toString());

          dlg.msgPn2.etInputFolder.preferredSize.width = 550;

          dlg.msgPn2.etInputFolder.helpTip = "Choose a folder of images to process.";

           

           

          dlg.msgPn2.btnBrowse = dlg.msgPn2.add("button", undefined, strButtonBrowse);

          dlg.msgPn2.btnBrowse.helpTip = "Select a folder of images to process.";

          dlg.msgPn2.btnBrowse.onClick = function() {

            var defaultFolder = dlg.msgPn2.etInputFolder.text;

            var testFolder = new Folder(dlg.msgPn2.etInputFolder.text);

            if (!testFolder.exists) {

               //defaultFolder = "~";

               defaultFolder = imagePath;

            }

            // var selFolder = Folder.selectDialog(dlg.msgPn2.etInputFolder.text, defaultFolder);

            dlg.selInputFolder = Folder.selectDialog(dlg.msgPn2.etInputFolder.text, defaultFolder);

            if ( dlg.selInputFolder != null ) {

                  dlg.msgPn2.etInputFolder.text = dlg.selInputFolder.fsName;

              }

            //dlg.msgPn2.defaultElement.active = true;

          }

          • 2. Re: Folder browsing dialog always returns the application's folder, not the one I selected
            xbytor2 Level 4
            var f = Folder();
            var outputFolder = f.selectDlg("Output folder:");
            $.write(outputFolder);