3 Replies Latest reply on Feb 10, 2016 12:15 AM by Kasyan Servetsky

    Wanna select multiple folders in the open dialog box, but it’s impossible, isn’t it?

    Kasyan Servetsky Level 5

      Hi forum,

       

      The File and Folder objects have openDlg() method. The former has also the multiSelect parameter, the latter doesn’t.

      I wish I could also have it for the Folder so I could ctrl/shift select multiple folders instead of picking up a folder and processing all its subfolders.

      Maybe I’m missing something obvious or there’s an workaround to make such a dialog box.

       

      Regards,

      Kasyan

        • 1. Re: Wanna select multiple folders in the open dialog box, but it’s impossible, isn’t it?
          Loic.Aigon Adobe Community Professional

          Hi Kasyan,

           

          I am a bit confused by you assumption. As far as I can see in the DOM, although a Folder object can bederivated from a generic File object, the openDialog and by extension openDlg are Files instance methods only. The Folder instance on the contrary has a selectDialog() and selectDlg() method.

           

          I tried just in case to call openDialog and openDlg on both the Folder class and Folder instance, and it throwed an error quite unsurprisingly.

           

          So I guess the only workaround would be to build your own folder selection window.

           

          FWIW,

           

          Loïc

          • 2. Re: Wanna select multiple folders in the open dialog box, but it’s impossible, isn’t it?
            Loic.Aigon Adobe Community Professional

            As suggested, a possible approach :

             

            Folder.prototype.selectMultipleDialog = function (prompt,multiselect){
              var w = new Window('dialog','MultipleSelectDialog'),
              st,
              ls,
              btnGp,
                koBtn,
                okBtn,
                folderFilter = function(f){
                    return (f instanceof Folder)
                },
                u,
                folders = this.getFiles(folderFilter),
                getFolderNames = function(foldersObjectArray){
                    var n = foldersObjectArray.length,
                    namesArray = [];
                    while ( n--){
                        namesArray[n] = decodeURI(foldersObjectArray[n].name);
                    }
                    return namesArray;
                },
                folderListItems = getFolderNames(folders),
                n = 0;
               
              
               
                st = w.add('statictext',u,prompt);
                ls = w.add('listbox',undefined, folderListItems, {multiselect:multiselect} );
            
                btnGp = w.add('group');
               
                koBtn = btnGp.add('button',u,'Cancel');
                okBtn = btnGp.add('button',u,'Select');
            
            
                koBtn.onClick = function(){
              w.close(0);
              }
            
            
              okBtn.onClick = function(){
              w.close(1);
              }
               
                ls.onChange = function() {
                    okBtn.enabled = ls.selection!==null;
                }
               
                w.preferredSize.width = 450;
                w.alignChildren = ["fill","top"];
                ls.preferredSize.height = 200;
                btnGp.alignChildren = ["right","top"];
            
            
              okBtn.enabled = false;
            
                if ( w.show()==1 ){
              if ( ls.selection instanceof Array ) {
              n = ls.selection.length;
                        while ( n-- ) folders[ls.selection[n].index].execute();
              }
              else {
              folders[ls.selection.index].execute();
              }
              }
            }
            
            
            var fo = Folder.desktop;
            fo.selectMultipleDialog("test", true)
            
            

             

            HTH

             

            Loic

            www.ozalto.com

            • 3. Re: Wanna select multiple folders in the open dialog box, but it’s impossible, isn’t it?
              Kasyan Servetsky Level 5

              Thank you very much for your quick reply, Loic!

               

              Regards,
              Kasyan