3 Replies Latest reply on Sep 6, 2016 3:57 AM by JJMack

    Layer group Folder creation Automation

    Vfxvenkat98 Level 1


           In the active document i need to create layer groups in Photoshop with the image names from the folder.


      Step 1. Select the folder which contains all images in .jpg format

      Step 2. by using the file names as reference the script want to create layer groups with the images of the selected folder

      (If the images name is brooklyn.jpg/pumpkin.jpg/grasshoper.jpg/) (in the document layer groups names as brooklyn,pumpkin.etc)


      Does it is possible to create all layer groups via automation.


      Thanks in Advance.

        • 1. Re: Layer group Folder creation Automation
          natrev Level 3

          Hi Venkat,

          Try this code...


          #target photoshop
          else{alert("No Image in use!")}
          function main(){
              var docRef=app.activeDocument;
              var myFolder = Folder.selectDialog ("Select Folder!");
              var myFiles = myFolder.getFiles ("*.jpg");
              for(var i = 0; i < myFiles.length; i++){
                  var theFile = app.open(File(myFiles[i]));
                  var theFileName=theFile.name.replace(/\.[^\.]+$/, ''); 
                  theFile.backgroundLayer.duplicate (docRef, ElementPlacement.PLACEATBEGINNING);
                  layRef=docRef.layers.getByName ("Background copy");            
                  var laySet=docRef.layerSets.add();  
                  layRef.moveToEnd (laySet);


          - yajiv

          • 2. Re: Layer group Folder creation Automation
            Vfxvenkat98 Level 1

            thanks yajiv awesome works fine .if it is possible to select only the images not folder.

            • 3. Re: Layer group Folder creation Automation
              JJMack Most Valuable Participant

              That would be possible but programming would be more complex to build the file list and be able to select image located in different folders.  You could look at script like Load files into a stack which does that.  It is much more than just opening  a folder selection dialog or file selection dialog. You need to design a SictptUI dialog that you can repeatitly use folder selection and file selection dialogs to build up the file list you want to process. Once the file list is built you use the main scriptUI dialog button to process the completed list.