3 Replies Latest reply on Dec 28, 2015 4:48 AM by Johnwhite

    Copy foldername and specific indd files.

    Dapeamel Level 1

      Hello guys

      I need a function,


      there is first a dialog-window that appears, from the dialog-window I select some indd files and pressed ok.(that have not to be all indd files from the folder)

      then appears a new dialog window so I can select a target to copy the selected files into also, copy the foldername from the selected indd files location and create that folder and put the files when I have selected a target.

      finally  create a textfile to save all indd filenames in / or if its possible to tag them in another way so I got them in.

      I know in mac finder you can put a color on files.


      Could someone help me out?


      Thank you in advance


      All Adobe Members


        • 1. Re: Copy foldername and specific indd files.
          Chinnadk Level 4



          Try this.


          var _files = File.openDialog("Select indesign files","*.indd",true),
              tarFolder = Folder.selectDialog("Select the target folder"),
              _parent = _files[0].parent.toString().replace(_files[0].parent.parent,"");
          new Folder(tarFolder + _parent).create();
          var filenames = "";
          var txtfile = new File(tarFolder + _parent + "/FileName.txt");
          for(var i=0;i<_files.length;i++)
                  _files[i].copy(new File(tarFolder + _parent + "/" + _files[i].name));
                  filenames +=_files[i].name + "\r";




          • 2. Re: Re: Copy foldername and specific indd files.
            Dapeamel Level 1

            Works like a charm,


            How do I set a default path for the FileDialog?


            here is a old code I used to do that with,


            function CopyStep1()
            var myPath = (File($.fileName).parent.parent.parent.fullName).split("/Kommuni/LaRe/LareAUTO/");
            var jobName=(myPath[1]); // filtrera bort jobbnummret för att kunna plocka parrent from aktiv path.
            var myJobnr= (File($.fileName).parent.parent.parent.fullName);
            mFolder = Folder(myJobnr);
            mFolder = mFolder.selectDlg();
              if(mFolder != null)
              var myFiles = mFolder.getFiles('*.indd');  
              for (i = 0; i < myFiles.length; i++)  
              var myFile = myFiles[i];  
              destFile1= new File(MYmyFile.name);// to create an object  
              myFiles[i].copy (destFile1);   

            Thank you so much in advance sir

            • 3. Re: Copy foldername and specific indd files.
              Johnwhite Level 1

              Hi Chinna


              Could make script for simply copy indd files from target folder to designated folder like:  myFiles[i].copy(~/Desktop/BACKUP/) ?