3 Replies Latest reply on Nov 7, 2013 1:08 AM by lglmrc

    Open multiple .indd files

    lglmrc Level 1


      usually when I have to ask for opening a single .indd file I use something like this:


      fileToOpen = File.openDialog("Open a document");

      myDocument = app.open(File(fileToOpen.fullName));


      But what if I have to open multiple files at once (eg. selecting them from the Desktop)?


      I read from the Indesign object model that the "open" function of the "application" object can accept an array of files.. am I right?


      Thanks in advance

        • 1. Re: Open multiple .indd files
          Mi_D Level 3

          try below code


          var fileFilters = "InDesign:*.indd*";

          var myFolder = Folder.selectDialog ("choose Folder", fileFilters, false);

          var files = myFolder.getFiles("*.indd");

          for(i = 0; i < files.length; i++)


                 var theDocument = app.open(File(files[i]), true);



          • 2. Re: Open multiple .indd files
            Laubender Adobe Community Professional & MVP

            @lglmrc – the openDialog() method comes with another argument for opening multiple files. That argument is set to "false" by default.
            Setting it to "true" is the key here:


            var FilesToOpen = File.openDialog("Open one or more documents", true);
            for(var n=0;n<FilesToOpen.length;n++){


            Alternatively there is the openDlg() method, that also comes with the second argument.


            See also:




            File openDialog (prompt: string[, filter: any=null][, multiSelect: bool=false])


            Opens a dialog so the user can select one or more files to open.

            Opens the built-in platform-specific file-browsing dialog in which a user can select an existing file or multiple files, and creates new File objects to represent the selected files.


            • If the user clicks OK, returns a File object for the selected file, or an array of objects if multiple files are selected.

            • If the user cancels, returns null.


            • 3. Re: Open multiple .indd files
              lglmrc Level 1

              Great! I knew there had to be a trick! Thanks very, very much