11 Replies Latest reply on Jul 17, 2014 6:25 AM by Dapeamel

    Folder Array

    Dapeamel Level 1

      Hello guys


      How do I make an array to create all theese folders?


      if they not exists create them


      here is my code so far




      function createFolderStructure()
      var a = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/_project_BACKUP");
      var b = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/blåkopior i 34xxxx_BACKUP");
      var c = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/delivery_BACKUP");
      var d = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/DTP_BACKUP");
      var e = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/inter_BACKUP");
      var f = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/script_BACKUP");
      var g = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/source_BACKUP");
      var h = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/translation to_BACKUP");
      var i = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/validation 1_BACKUP");
      var j = new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/validation 2_BACKUP");
      if (!a,b.exists)




      Thank you in advance

      all good Adobe Members!

        • 1. Re: Folder Array
          Chinnadk Level 4



          Try this.


          function createFolderStructure()
              var folders = [];
              folders[0] = Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/_project_BACKUP");  
              folders[1] = Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/blåkopior i 34xxxx_BACKUP");  
              folders[2] = Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/delivery_BACKUP");  
              folders[3] = Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/DTP_BACKUP");  
              folders[4] = Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/inter_BACKUP");  
              folders[5] = Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/script_BACKUP");  
              folders[6] = Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/source_BACKUP");  
              folders[7] = Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/translation to_BACKUP");  
              folders[8] = Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/validation 1_BACKUP");  
              folders[9] = Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/validation 2_BACKUP");
              for(var i=0;i<folders.length;i++)
                              new Folder(folder[i]).create()




          • 2. Re: Folder Array
            TᴀW Adobe Community Professional & MVP

            To make an array of Folders, something like this should work:


            var myFolders = [];





            Then you can simply loop through the array and create the folders:


            for (var j = 0; j < myFolders.length; j++){




            ... if I've understood your question correctly.

            • 3. Re: Folder Array
              Dapeamel Level 1

              Thank you for a very fast answer


              that is appreciated!



              Cheers Daniel

              • 4. Re: Folder Array
                Jump_Over Level 5



                There is no need to split this or to build any array. Method Folder.create() works if folder !exists and returns true if folder exists already, so:

                new Folder("/Volumes/Arkiv/XXXXXXX/XXXXXX/_project_BACKUP").create(); 

                does a job in both cases.



                • 5. Re: Folder Array
                  TᴀW Adobe Community Professional & MVP

                  True, but perhaps he needs a reference to each folder after it's been created.

                  • 6. Re: Folder Array
                    Jump_Over Level 5

                    True, but his reference is created locally inside a function and looks like unuseful

                    • 7. Re: Folder Array
                      TᴀW Adobe Community Professional & MVP

                      True, but looks can be deceiving.


                      Anyway, you're probably right.

                      • 8. Re: Folder Array
                        Dapeamel Level 1

                        here is my final code but I still have a little question,

                        How do I replace "XXXXXX" with a variable in my code




                        here is the final code below


                        function Createfolders()
                        new Folder("/Volumes/Arkiv/testproject_BACKUP/XXXXXX/_project_BACKUP").create(); ;    
                        new Folder("/Volumes/Arkiv/testproject_BACKUP/XXXXXX/_project_BACKUP/TM_Big Book_BACKUP").create(); ;    
                        new Folder("/Volumes/Arkiv/testproject_BACKUP/XXXXXX/blåkopior i 34xxxx_BACKUP").create(); ;    
                        new Folder("/Volumes/Arkiv/testproject_BACKUP/XXXXXX/delivery_BACKUP").create(); ;



                        Thank you so much good members

                        really appreciated.

                        • 9. Re: Re: Folder Array
                          Jump_Over Level 5



                          One of solution could be like this:

                          function Createfolders(jobName) 
                            new Folder("/Volumes/Arkiv/testproject_BACKUP/" + jobName + "/_project_BACKUP").create(); ;     
                            new Folder("/Volumes/Arkiv/testproject_BACKUP/" + jobName + "/_project_BACKUP/TM_Big Book_BACKUP").create(); ;     
                            new Folder("/Volumes/Arkiv/testproject_BACKUP/" + jobName + "/blåkopior i " + jobName + "_BACKUP").create(); ;     
                            new Folder("/Volumes/Arkiv/testproject_BACKUP/" + jobName + "/delivery_BACKUP").create(); ; 



                          • 10. Re: Folder Array
                            Dapeamel Level 1

                            Thank you sir I gonna test the code now, comming back with result

                            • 11. Re: Folder Array
                              Dapeamel Level 1

                              Here is my final code works like a charm

                              another question haha!


                              I using this code snippet to get active path and correct information about my job ID




                              fromt the code above I get "/Kommuni/auto/lol/213442/" in the alert window



                              How do I make my script creates the folder 213442

                              (replace the variable jobName with 213442)


                              new Folder("/Volumes/Arkiv/test_BACKUP/" + jobName + "/delivery_BACKUP/PDF_BACKUP").create(); ;  


                              the final result ("/Volumes/Arkiv/test_BACKUP/213442/delivery_BACKUP/PDF_BACKUP")


                              function Createfolders()
                              var jobName=("XXXXXX");
                              new Folder("/Volumes/Arkiv/test_BACKUP/" + jobName + "/delivery_BACKUP/PDF_BACKUP").create(); ;   
                              new Folder("/Volumes/Arkiv/test_BACKUP/" + jobName + "/script_BACKUP").create(); ; 



                              Do you understand what I mean tell me then if not.


                              Thank you in advance.