8 Replies Latest reply on May 26, 2014 6:55 AM by c.pfaffenbichler

    script to import layers in other file

    agathepicture

      Hello,

       

      i'm new to this forum but i use a lot of scripting for my workflow... and there is something i need to do  :

       

      i need to import all groups and layers from a local PSD file (that is "my master" with all guidelines from my client : position, spaces, size of product in the picture)

      in a other open PSD file to compose the scene,

      and i have 10-50 files to do each day.. and i cannot script this part, wich is a problem for me

       

      somebody has the answer  ?

       

      Tanx a lot

       

      Agathe

        • 1. Re: script to import layers in other file
          c.pfaffenbichler Level 9

          Is placing the file as a Smart Object is useless because you need the full Layer structure in the receiving file?

           

          What trips you up so far?

          How do you want to implement the thing – call a Script with the receiving document open, have a Script with a file or folder selection dialog to select the receiving documents, …?

           

          I recently posted something that groups all Layers,

          How do I select similar layers in Photoshop CC?

          that might provide a starting pint as one can translate the group to another document.

           

          Are unlinked (edited) Layer Masks/Vector Masks a possibility in the client file?

          • 2. Re: script to import layers in other file
            agathepicture Level 1

            Yes i need all the layers structure of the first file, i tried smart object but doesn't match this condition

             

            i'd better like to call a script with the second document open, but i'll take the solution that is possible to do !

             

            i read your other post, in fact all my layers are already grouped in my first document, with all layers names and all tidy

            is there a way to script something like : "open this file and " translate the group to another document" ?

             

            in fact so far i am not able to go further than "classical" action in photoshop (registering in live the chain of action in my files) script menu ... i never found anywhere (in France) to teach me professionally the "command line" scipt that you use i guess.. i'm willing to but don't know where to start on the web (if you have an adress), and it is really limitating me for my work !

             

             

            tanx for your help

             

            Agathe

            • 3. Re: script to import layers in other file
              c.pfaffenbichler Level 9

              Supposing the receiving image is open and active and the client file really has everything in just on Group and this Group is the topmost Layer this might help:

              // 2014, use it at your own risk;

              #target photoshop

              if (app.documents.length > 0) {

              var myDocument = app.activeDocument;

              var aFile = selectFile(false);

              if (aFile) {

              var theClientFile = app.open(aFile);

              var theGroup = theClientFile.layers[0];

              theGroup.duplicate(myDocument, ElementPlacement.PLACEATBEGINNING);

              theClientFile.close(SaveOptions.DONOTSAVECHANGES)

              }

              };

              ////////////////////////////////////

              ////////////////////////////////////

              ////////////////////////////////////

              ////// select file //////

              function selectFile (multi) {

              if (multi == true) {var theString = "please select files"}

              else {var theString = "please select one file"};

              if ($.os.search(/windows/i) != -1) {var theFiles = File.openDialog (theString, '*.jpg;*.tif;*.psd;*.png', multi)}

              else {var theFiles = File.openDialog (theString, getFiles, multi)};

              ////// filter files  for mac //////

              function getFiles (theFile) {

                  if (theFile.name.match(/\.(jpg|tif|psd|png)$/i) || theFile.constructor.name == "Folder") {

                      return true

                      };

                };

              return theFiles

              };

               

              To forego the file selection you could drop the lines referring to that and write the file path into (edited)

              var theClientFile = app.open(new File(/*insert the proper path here*/));

               

              Edit:

              // 2014, use it at your own risk;
              #target photoshop
              if (app.documents.length > 0) {
              var myDocument = app.activeDocument;
              var theClientFile = app.open("…");// include the file’s fullName instead of the periods
              var theGroup = theClientFile.layers[0];
              theGroup.duplicate(myDocument, ElementPlacement.PLACEATBEGINNING);
              theClientFile.close(SaveOptions.DONOTSAVECHANGES)
              };
              
              • 4. Re: script to import layers in other file
                c.pfaffenbichler Level 9

                Just to make sure:

                Paste the code from the previous into a new file in ExtendScript Toolkit and save it as a jsx-file into Photoshop’s Presets/Scripts-folder.

                After restarting Photoshop the Script should be available under File > Scripts and can be assigned a Keyboard Shortcut directly, recorded into an Action, be used in a Configurator-Panel or started from ExtendScript Toolkit directly.

                 

                As for learning JavaScript for Photoshop you might want to check out »Adobe Intro To Scripting.pdf« and »Photoshop-CS6-Scripting-Guide.pdf«.

                • 5. Re: script to import layers in other file
                  c.pfaffenbichler Level 9
                  the "command line" scipt

                  I don’t think the term is quite appropriate for automating task in Photoshop with Scripting.

                   

                  As for an introduction to Photoshop Scripting this book

                  Power, Speed & Automation with Adobe Photoshop: (The Digital Imaging Masters Series): Geoff Scott, Jeffrey Tranberry: 97…

                  might be of interest, but it is not dedicated to Scripting primarily.

                  • 6. Re: script to import layers in other file
                    ojodegato Level 1

                    This post might help you get started with Photoshop Scripting.

                    How to begin with Photoshop scripting

                    • 7. Re: script to import layers in other file
                      agathepicture Level 1

                      tanx a lot for all your informations,

                       

                      c.pfaffenbichler  i will first read all the pdf to be sure tu use correctly your code !

                      i'll let you know how i deal with your code

                       

                      Do you know where i can find the two PSD ref you gave me ? i'll try a google search

                      Edit : i found the two PDF

                       

                      in fact I have this book "power, speed..." but i didn't really find a solution, i'll take a better look

                       

                      ojodegato  tank you for your link, big help too , i need to learn to deal with all this to go further in my work !

                       

                       

                      really guys, so much help in one post... it's been months i'm looking to go further... tanx !

                       

                      A

                      • 8. Re: script to import layers in other file
                        c.pfaffenbichler Level 9

                        Adobe Photoshop Scripting | Adobe Developer Connection

                        »Adobe Intro To Scripting.pdf« should be part of the ESTK installation.