8 Replies Latest reply on Sep 21, 2015 7:36 AM by c.pfaffenbichler

    Saving files with layer name

    shanebettsphotog

      Hi

       

      I have a PS file I need to version out to 7 versions of about 45 variations. I have all the layers and groups named so it makes sense and it occurs to me that the correct name for the outputted jpegs would actually be the same name as the current layer.

       

      Does anyone know a way, either with actions or batch automate, to save a file using the currently selected layer as the file name? The file naming options in batch seem really limited.

       

      TIA

      Bettsy

        • 1. Re: Saving files with layer name
          c.pfaffenbichler Level 9

          Please describe the process in more detail.

          And how are existing files of the same name to be handled?

          • 2. Re: Saving files with layer name
            shanebettsphotog Level 1

            There are no existing files of the same name. I have a master PSD which has a number of layers and groups. I show a layer or group and save as a JPG with that layer/group name (so it's not hard to select the layer/group as I show it). I then show the next or group layer up, rinse and repeat. End result is an unchanged master PSD (aside from hide/show settings) and a folder full of versions named "layer1.jpg, group2.jpg etc".

             

            It seems to me that I need a script (or I need to write one) that allows me to select the name of a layer or group, copy it to the clipboard and then paste it into the naming field of the save as dialogue (which is exactly what I'm doing now, only manually).

             

            BTW, if I were to attempt to save over existing files, I'd be fine if it just replaced them (they're easy to replicate) or returned an error or a dialogue asking me what to do. Not fussy. There may even be a way using Applescript to aide and abet...

            • 3. Re: Saving files with layer name
              c.pfaffenbichler Level 9
              There may even be a way using Applescript to aide and abet...

              I am a Mac user myself but writing a Photoshop Script in AppleScript seems like such a bad idea …

               

              So the Layer the name of which is to be used is not the selected one but the only one visible?

              Which jpg settings?

              Where is the file to be saved to?

              • 4. Re: Saving files with layer name
                shanebettsphotog Level 1

                :-) Not as dangerous as using Automator...

                 

                The layer is not the only one visible, not even the upper-most. But, as I will need to make it visible, I may as well select it as well and so it will become the active layer. I can do that much in Actions.

                 

                Jpeg settings would be max quality and the directory could be a predefined one (ie - ~/Desktop/jpegs go here/) from where I can then move the files to their appropriate home once I'm done.

                 

                I'm just reading the ExtendScript manual to write a script for this. I've done thins kind of thing before in After Effects and Filemaker but, of course, every time I have to go back there, it's been a year and I have to start learning from scratch. Kinda hoping there's another way:-)

                 

                Thanks for your efforts, BTW. I really appreciate it.

                • 5. Re: Saving files with layer name
                  c.pfaffenbichler Level 9

                  Maybe this can provide some help.

                  Change the quality to 12 and instead of

                  thedoc.saveAs((new File(docPath+'/'+basename+'.jpg')),jpegOptions,true);
                  
                  

                  use

                  thedoc.saveAs((new File(docPath+'/'+thedoc.activeLayer.name+'.jpg')),jpegOptions,true);
                  
                  

                  and define docPath as the path you want ("~/Desktop/jpegs go here").

                  // saves jpg into same folder;
                  // be advised: this  overwrites existing jpgs of the same name without prompting.
                  // 2010, use it at your own risk;
                  #target photoshop;
                  if (app.documents.length > 0) {
                  var thedoc = app.activeDocument;
                  // getting the name and location;
                  var docName = thedoc.name;
                  if (docName.indexOf(".") != -1) {var basename = docName.match(/(.*)\.[^\.]+$/)[1]}
                  else {var basename = docName};
                  // getting the location, if unsaved save to desktop;
                  try {var docPath = thedoc.path}
                  catch (e) {var docPath = "~/Desktop"};
                  // jpg options;
                  var jpegOptions = new JPEGSaveOptions();
                  jpegOptions.quality = 9;
                  jpegOptions.embedColorProfile = true;
                  jpegOptions.matte = MatteType.NONE;
                  //save jpg as a copy:
                  thedoc.saveAs((new File(docPath+'/'+basename+'.jpg')),jpegOptions,true);
                  //that’s it; thanks to xbytor;
                  };
                  
                  
                  • 6. Re: Saving files with layer name
                    shanebettsphotog Level 1

                    Wow! Thank you so much (and xbytor). I'll give that a run and see how it goes. Awesome.

                    • 7. Re: Saving files with layer name
                      shanebettsphotog Level 1

                      Yup. That works a treat. You rock. Thanks!

                      • 8. Re: Saving files with layer name
                        c.pfaffenbichler Level 9

                        You’re welcome.