2 Replies Latest reply on Aug 23, 2010 5:10 PM by StrongBeaver

    Script Update ?

    StrongBeaver Level 3

      Can the script below be updated for Photoshop CS5, as well is it possible to add the ability or an option maybe though configurator to have this script Save a Layer Group by a specific name?

       

      #target photoshop
      
       
      
      main();
      
       
      
      // It calls the other functions to change the visibility of the layer, duplicate it
      
      // another document in PSD format and save the document.
      
      function main(){
      
      if(documents.length > 0 && app.activeDocument.activeLayer.typename == "LayerSet") {
      var layerName=activeDocument.activeLayer.name;
      var savePath = decodeURI(activeDocument.path);
      var theFileName = app.activeDocument.name;
      // thanks to xbytor for the regexp;
      var baseName = theFileName.match(/(.*)\.[^\.]+$/)[1];
      if (baseName.indexOf(layerName) != -1) {
      var saveName = baseName.slice(0, baseName.indexOf(layerName)+1)
      }
      else {
      var saveName = baseName;
      };
      var theFile = dupLayers();
      var SaveFile= File(savePath+"/"+saveName+"_"+layerName+".psd");
      SavePSD(SaveFile, theFile);
      theFile.close(SaveOptions.DONOTSAVECHANGES);
      }
      else {alert ("select a layer group, not a solo layer")}
      };
      
      //copies the layers in a new document
      
      function dupLayers() {
      
              var desc143 = new ActionDescriptor();
      
              var ref73 = new ActionReference();
      
              ref73.putClass( charIDToTypeID('Dcmn') );
      
              desc143.putReference( charIDToTypeID('null'), ref73 );
      
              desc143.putString( charIDToTypeID('Nm  '), "_"+activeDocument.activeLayer.name+".psd" );
      
              var ref74 = new ActionReference();
      
              ref74.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
      
          desc143.putReference( charIDToTypeID('Usng'), ref74 );
      
          executeAction( charIDToTypeID('Mk  '), desc143, DialogModes.NO );
      
      return app.activeDocument
      
      };
      
      //saves the file in PSD format
      
      function SavePSD(saveFile, theFile){
      
      psdSaveOptions = new PhotoshopSaveOptions();
      
      psdSaveOptions.embedColorProfile = true;
      
      psdSaveOptions.alphaChannels = true;
      
      theFile.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
      
      };
      
        • 1. Re: Script Update ?
          JJMack Most Valuable Participant

          StrongBeaver wrote:

           

          Can the script below be updated for Photoshop CS5, as well is it possible to add the ability or an option maybe though configurator to have this script Save a Layer Group by a specific name?

           

          
          

          Using CS5 32 bit  I opend a file create a layer group out of some layers targeted the layer group and ran this scrip and it saved a new document FileName_GroupName.PSD it worked as is  just file. It uses the current filename and target layer group to create the output filename ans saves a psd file in the same folder as the source  file???

          • 2. Re: Script Update ?
            StrongBeaver Level 3

            Thanx I hope you could help me adjust my other script ?