1 Reply Latest reply on Dec 8, 2014 12:15 AM by CarlosCanto

    Script that gives specific names to layers - from bottom to the top

    memcus

      Hi,

       

      This is probably an easy one for anyone with JavaScript experience.

      I have 35 layers that I want to give specific names to (now they're named liked "layer 1, 2, 3" - but sometimes this won't be consistent, so some numbering might be skipped,

      in other words I can't rely on a script that renames a specific "Layer 1" to "my name").

       

      I want to rename each layer from the bottom to the top, i.e.:

      [...]

      "Power"

      "Yellow"

      "Hello"

       

      With the script working its way up from the bottom to the top.

      How do I accomplish this?

       

      Thank you so much for you taking your time to help me.

        • 1. Re: Script that gives specific names to layers - from bottom to the top
          CarlosCanto Adobe Community Professional & MVP

          something like this?

          renameLayersFromBottomUp.PNG

           

          if so, type your names in a text frame, select it and run this script

           

          // rename Layers from the bottom up
          // carlos canto
          // https://forums.adobe.com/thread/1653162
          
          // type your names in a text frame, select it and run this script
          var idoc = app.activeDocument;
          var itext = idoc.selection[0];
          var a_names = itext.contents.split ('\r').reverse();
          
          
          var namecount = a_names.length;
          var layercount = idoc.layers.length;
          var counter = Math.min(namecount, layercount);
          
          
          for (i=layercount-1, j=0; i>=layercount-counter; i--, j++) {
              var ilayer = idoc.layers[i];
              ilayer.name = a_names[j];
          }