1 Reply Latest reply on Jul 23, 2013 11:50 AM by Michael L Hale

    How do I create a script to do this?

    content_love

      I have a photoshop file with several layers...about 100. I want to put each layers into it's own group. The name of the group must be the same as the name of the layer.

       

      I tried creating a action to do this but it did not work right. It only works for one layer selected individually. If I select multiple layers, then it forms nested groups.

       

      I was told that I can't do this using an action and I would need a script for this.

       

      How do I create this script?

       

       

      I am using adobe photoshop cs6 ( I think) , windows 7.

        • 1. Re: How do I create a script to do this?
          Michael L Hale Level 5

          This assumes that none of the layer are already in layerSets( group ) and none have layer locking.

           

          if(app.documents.length>0){
              var doc = app.activeDocument;
              while(!doc.artLayers[0].isBackgroundLayer && doc.artLayers.length>0  ){
                  var newSet = doc.layerSets.add();
                  newSet.name = doc.artLayers[0].name;
                  doc.artLayers[0].move(newSet,ElementPlacement.INSIDE);
              }
          }