5 Replies Latest reply on Jan 25, 2017 4:01 AM by Silly-V

    Scripting a save command

    richardw26639360

      Hello all,

       

      I've set up a script that locks all layers but one. This is the standard format we use at the job site. It works fine by itself but adding in the save command seems to override the loop and not do anything but save. I tried adding a sleep command but that didn't help. How can I execute the loop first and then save once the loop is complete?

       

      doc = app.activeDocument;

      infoSheet= doc.layers ["SGS Info Sheet"];

       

      with (doc) {  

          for (var i = 0; i <layers.length; i++) {

              with (layers[i]) {

                   if (locked == false){

                       activeDocument.layers[i].locked= true;

                       }}}}

       

      infoSheet.visible = true;

      infoSheet.locked = false;

       

      $.sleep(1000)

       

      app.executeMenuCommand ('save');