5 Replies Latest reply on Jun 29, 2010 3:27 AM by Dave_3

    Folder selection


      Hi all,


      I've got a script to set up a document and import a folder of files to it. I've got a couple of questions about the UI dialogs, now!


      1) I'm using the Folder.selectDialog() function to choose the folder where the images are. I'd really like to be able to set a default folder for this to aim at, rather than the usual Desktop default, where you then have to click through five or six other layers to get to the correct folder.

      Is there a way of doing this?


      2) I'm also creating a dialog box for the user to set up the running heads for the document. That's working fine, but I'd really like to be able to integrate the "Choose folder" section into that dialog box. Is there an easy way to put that into an InDesign dialog?


      Thanks in advance!


        • 1. Re: Folder selection
          Kasyan Servetsky Level 5


          var myFolder = new Folder ("/D/Temp");
          myFolder = myFolder.selectDlg();


          2) You can add a button to the dialog for selecting a folder -- if you need an example, check out this script.



          • 2. Re: Folder selection
            Dave_3 Level 1

            Brilliant, thanks!


            So I was really just missing the constructor for a folder object. Is that the general syntax for constructors? (So a new, say, MasterSpread could be constructed with myMasterSpread = new MasterSpread("NameOfSpread") ?)

            • 3. Re: Folder selection
              [Jongware] Most Valuable Participant

              If only it was that simple!

              The Folder class has a 'constructor' method, and it's one of the few. Others are Array, Boolean, Date, Error, File, Function, Number, Object, RegExp, Socket, String, UIEvent, and ScriptUI Window.

              If I remember correctly you need a constructor if creating a new object requires more than a simply allocation of an amount of memory.


              Your line


              myMasterSpread = new MasterSpread("NameOfSpread");


              just gives an error "MasterSpread does not have a constructor". Even if it did work, you'd have a master spread somewhere in memory -- not linked to a document or something (its 'parent' is a Document but that's a read-only property).

              • 4. Re: Folder selection
                Kasyan Servetsky Level 5

                No, master spread is a part on InDesign's DOM --  you create it like so:



                File and Folder objects are the part of Adobe ExendScript and common for all scripted applications: InDesign, Photoshop, Illustrator, etc.



                • 5. Re: Folder selection
                  Dave_3 Level 1

                  Ah, I see. I think...


                  I have been creating various master spreads using the app.document.masterSpreads.add() method, but I'd been wondering if there were another way. Still, all is well, and the script that I was intending to write is working as I want it to, so I'm pretty happy!


                  Thanks again, and I'm sure I'll be bothering you with more questions later...