2 Replies Latest reply on Aug 23, 2016 8:33 PM by kylwell

    Script to swap layer names between files

    kylwell

      I need to rename layers based on another file. Both have the same # of layers in the same order and a sequential number won't help. Does anybody know of a script that can do this? My last bit of programming was recorded on a magnetic cassette tape and I have no idea of where to start with scripting so I'm throwing myself on the mercy of the forums.

        • 1. Re: Script to swap layer names between files
          CarlosCanto Adobe Community Professional & MVP

          here you go, the script doesn't have any error checking, so make sure both files have indeed the same layer structure.

           

          open both files, make sure the active document is the one that needs the layer names changed.

           

          // copy layer names from Doc A to Doc B
          // https://forums.adobe.com/thread/2182653
          
          
          var destDoc = app.activeDocument; // the document to copy layer names to
          var sourceDoc = app.documents[1]; // the document to copy layer names from
          
          
          var sourceLayer, destLayer;
          
          
          for (var a=0; a<destDoc.layers.length; a++) {
              destLayer = destDoc.layers[a];
              sourceLayer = sourceDoc.layers[a];
              destLayer.name = sourceLayer.name;
          }
          
          1 person found this helpful
          • 2. Re: Script to swap layer names between files
            kylwell Level 1

            Awesome! Just wanted to say thanks!