7 Replies Latest reply on Jul 27, 2016 8:26 AM by tssee@imgof.com

    Combine all your open documents in a single document

    Level 1

      Many times I find myself with many documents open and I have to select one by one to paste the original document

      there is a method to do this automatically?

       

      I would do this

      open documents

      1.png

      port of the original document

      2.png

      I've been to and I have found nothing about this problem.

        • 1. Re: Combine all your open documents in a single document
          natrev Level 3

          Hi Tssee,

           

          Try this Code in batch processing.

          PS: Record as action before run the batch process.

          Screen Shot 2016-07-26 at 6.44.41 pm.png

           

          #target photoshop
          var activeDoc = app.activeDocument; //This stores the currently active document to the variable activeDoc
          var DocName=activeDoc.name;
          var originalDoc = app.documents.getByName("Untitled-1.psd");
          main();
          function main(){    
              if(app.activeDocument.name!=originalDoc.name){
                  activeDoc.flatten;
                  var layerRef = activeDoc.artLayers[0].duplicate(originalDoc, ElementPlacement.PLACEATBEGINNING);
                  activeDoc.close( SaveOptions.DONOTSAVECHANGES );
                  var layRef=originalDoc.artLayers.getByName("Background copy");
                  layRef.name=DocName;
              }
          }
          

           

           

          - yajiv

          • 2. Re: Combine all your open documents in a single document
            JJMack Most Valuable Participant

            Someone on asked how to get all the pages in a PDF into a layer document for when opened by Photoshop each page was opened in its own document.

             

            So I wrote the a little script for them to the put all the open documents into a new document then close all the document that were open.

             

            The Close All but the new document is a prompted for option you can leave the documents open.  If they are layered document the new document will only have single composite layer for each document.

             

            StackOpenDoc.jsx

             

            /* ==========================================================
            // 2016  John J. McAssey (JJMack) 
            // Stack the open Document Visible layer composite into a new 300 DPI document
            // This script is supplied as is. It is provided as freeware. 
            // The author accepts no liability for any problems arising from its use.
            // ======================================================= */
            // enable double-clicking from Mac Finder or Windows Explorer
            #target photoshop // this command only works in Photoshop CS2 and higher
            // bring application forward for double-click events
            app.bringToFront();
            
            
            if (documents.length >= 2) { main(); }
            else alert("multiple Document are not open in Photoshop");
            ///////////////////////////////////////////////////////////////////////////////
            //                            main function                                  //
            ///////////////////////////////////////////////////////////////////////////////
            function main() {
              var orig_ruler_units = app.preferences.rulerUnits;
              var orig_display_dialogs = app.displayDialogs;
              app.preferences.rulerUnits = Units.PIXELS; // set the ruler units to PIXELS
              app.displayDialogs = DialogModes.NO; // Set Dialogs off
              var closeDocs  = prompt("Should documents be Close without saving?", "Yes");
              var canvasSize = new Array(); // what size canvas is needed
              canvasSize=getDocDementions(); // get max width and height of open documents
              app.togglePalettes(); // toggle off palette so Photoshop will not need to update them
              var doc = app.documents.add( canvasSize[0], canvasSize[1], 300, "Stacked Opened Documents", NewDocumentMode.RGB, DocumentFill.TRANSPARENT ); // create a new document
              //for (var i=0;i<documents.length-1;i++) { // stack a layer for the open document into the new document
              for (var i=documents.length-2;i>-1;i--) { // stack a layer for the open document into the new document
              app.activeDocument = documents[i]; // switch active document
              var layerName = app.activeDocument.name; // get document name
              app.activeDocument.selection.selectAll();           // select all
              try {app.activeDocument.selection.copy(true);} // copy composite of visible layers to clipboard
              catch (e) {try {app.activeDocument.selection.copy();} // copy composite of visible layers to clipboard
                catch (e) { } // empty 
              }
              app.activeDocument.selection.deselect(); // deselect
              app.activeDocument = documents[documents.length-1]; // switch to newly created document
              try { app.activeDocument.paste(); } // paste on composite of visible layers
              catch (e) { app.activeDocument.artLayers.add(); } // add an empty layer
              app.activeDocument.activeLayer.name=layerName; // label layer with Document name
              }
              if ( closeDocs == "Yes" ) closeAllButOne(); // close all opened document except the newly created document
              app.togglePalettes(); // toggle user's palettes back on
              app.runMenuItem(charIDToTypeID(("FtOn"))); // fit the document to the screen 
              app.displayDialogs = orig_display_dialogs; // Reset display dialogs 
              app.preferences.rulerUnits = orig_ruler_units; // reset units to original settings
              }
            ///////////////////////////////////////////////////////////////////////////////
            //                           main function end                               //
            ///////////////////////////////////////////////////////////////////////////////
            function getDocDementions(){
                width=0;
              height=0;
              for (var i=0;i<documents.length;i++) { // look at open document sizes
                 if (documents[i].width > width) width=documents[i].width;
              if (documents[i].height > height) height=documents[i].height;
              }
              return new Array(width, height); // return width and height
              }
            
            function closeAllButOne(){ // close all opened document except the newly created document
              while  (documents.length>1) {
              app.activeDocument = documents[0];
              activeDocument.close(SaveOptions.DONOTSAVECHANGES);
              }
              }
            
            • 3. Re: Combine all your open documents in a single document
              pixxxel schubser MVP & Adobe Community Professional

              Hi tssee@imgof.com,

              If I understand you right – try the out-of-box-script (in German Datei --> Skripten --> Dateien in Stapel laden …) in english File --> Scripts --> ??? Load Files into stack ???

               

              Does this works for you?

              • 4. Re: Combine all your open documents in a single document
                JJMack Most Valuable Participant

                I found that load files into stack has a problems with the new documents canvas size. When files and or Open documents have vastly different size canvas. It seems to use the size of one of the document or files canvas size to size new document canvas ..  Many of the stack layers may be larger than canvas size.  You may need to add canvas so the canvas size will not clip layers in the stack.

                • 5. Re: Combine all your open documents in a single document
                  Level 1

                  I tried with File -> Scripts -> ??? Load Files into Stack ???

                  the problem that I must first save documents

                   

                   

                  my work process and the following

                  Load the room and I open raw files in photoshop

                  then I would unite in a single document as shown in the picture above

                  • 6. Re: Combine all your open documents in a single document
                    JJMack Most Valuable Participant

                    The script I posted only works on open documents and they do NOT have to be saved. The can be new  unsaved documents.

                    • 7. Re: Combine all your open documents in a single document
                      Level 1

                      Thanks jjMack

                      and just what I needed

                      I do not mean saving open documents.