9 Replies Latest reply on Aug 3, 2014 4:02 PM by kharkins1

    Action scripts to save as with layer name

    kharkins1

      I need to write an action script to turn on a layer and then Save As or Save for the Web and have it automatically name the file by adding the visible layer name to the end of the file name. Is this possible?

        • 1. Re: Action scripts to save as with layer name
          Chuck Uebele Adobe Community Professional & MVP

          This sounds like what Generator all ready does.  What are you trying to do that different from Generator?

          • 2. Re: Action scripts to save as with layer name
            kharkins1 Level 1

            Well I actually didn't know about Generator until now.. but it doesnt do exactly what I want... unless I add a bunch more duplicated layers and group them differently. What I am looking to do is have have say 6 layers on and then the 7th layer be turned on, saved as a jpg or gif, then turn the 7th off, turn the 8th, saved as a jpg or gif, then turn the 8th off, turn the 9th, saved as a jpg or gif, and so on. I have an image that has 17 different colors, with 3 different locations these 17 colors can appear... with every color combination. YES, that is 17 x 17 x 17 = a lot of images! Do you still suggestion Generator?

            • 3. Re: Action scripts to save as with layer name
              kharkins1 Level 1

              BTW, I have a the desktop version of Photoshop CS6 not CC. Is there a download?

              • 4. Re: Action scripts to save as with layer name
                Chuck Uebele Adobe Community Professional & MVP

                No, there isn't a download for CS6.  I'm not sure of your layer structure.  Are any of these layers in groups?  If not, you can just loop through the layers by using your example of starting with the 7th layer (layers are numbered from the top down starting with 0.  I didn't test this, just wrote it.  But that the general gist of how you might be able to do this:

                 

                var doc = activeDocument

                for(i=doc.layers.length-6;i>-1;i--){

                doc.layers[i].visible = true

                var docName = doc.name.split(',')[0] + '_' + doc.layers[i].name

                 

                //put the rest of your code to save the file here.

                }

                • 5. Re: Action scripts to save as with layer name
                  Level 1

                  This is the code

                   

                  var doc = activeDocument

                  for(i=doc.layers.length-6;i>-1;i--){

                  doc.layers[i].visible = true

                  var docName = doc.name.split(',')[0] + '_' + doc.layers[i].name

                   

                  //put the rest of your code to save the file here.

                  }

                  • 6. Re: Action scripts to save as with layer name
                    kharkins1 Level 1

                    Great. Thanks! I will give this a try... but I did end up upgrading to CC to give Generator a try. Now that I have it, can you tell me if the best/fastest way to get all the images I need? Do I need to make 9,826 groups (17 x 17 x 17) of layers in one psd, with each folder/group to have all the layers needed to save out the image (including the background)? I am worried that if one layer of say 'green' is the wrong shade of green, how would I go about adjusting this? If I update one layer of green, how can I update all the other layers of 'green'? Also, if each folder has the background duplicated, I can't make a change to the item on this layer and have it update all the other layers that have the background right?

                    • 7. Re: Action scripts to save as with layer name
                      Chuck Uebele Adobe Community Professional & MVP

                      For what you're trying to do, I don't think Generator will work, and a script would be better.

                      • 8. Re: Action scripts to save as with layer name
                        kharkins1 Level 1

                        I have a new need with this same project. I have 12 separate .psd files per product (same product but in different color combinations). Each .psd has 144 layers with unique layer names. Once I open one file, I run an action script (recorded within PS) to update all the layers links, and rename the layers with the product sku # with a 3rd party Script. This sku # is the same # that all 12 files need to be updated with. The problem is that when i run this recorded script, I have to manually punch in the sku # for each file even though it is the same for everything because the script brings up a window each time it is called upon. The info doesnt stay in the script. THEN, the recorded scripts saves, then save as and the name of the file just stays the same and saves over itself... which is bad. I need it to save as a new name (1,2,3 or a,b,c would be fine) so I can rename later. Can you help me streamline the production of this project please so I dont have to sit here forever!?!?!

                        Thanks a million.

                        Kelly