15 Replies Latest reply on Jan 2, 2018 5:31 AM by JJMack

    "next document" issue?

    isy26814400 Level 1

      first of all, thanks to all of you who meant to help. and srry me for my bad english.

       

      my problem is a little bit wierd, i have an action that works fine like,

       

      select next document

      set selection

      cut

      close --> no

      paste

       

      when i batch it, with my template psd file and jpegs opened, it gets the jpegs, cut them, and paste them in to the template as layers.

      normally when batching operation close all the jpeg files and just template psd left, it gives the error "the object "next document".. bla bla" and i could close the message and continue to work on my template file with my all jpegs layered..

       

      but all of a sudden, now it closes the psd file also.

       

      the main issue is when one file opened left PS CS3 can still play the "select next document" command, normally i mean as default it shouldnt have to.

       

      and one more thing i noticed, when i have 2 files opened and just clicked the "select next document" command, it changes to "select previous document" automatically,

      when i click again it cycles between "previous" and "next"..

       

      soo plx help me, i want the "the object "next document" .. bla bla" error back, when i have just one file left opened..

       

      THX oxoxo

        • 1. Re: "next document" issue?
          Kukurykus Adobe Community Professional
          if (documents.length == 1) {
               if (len = (fls = Folder.selectDialog('SELECT FOLDER:').getFiles(/\.jpe?g$/i)).length) {
                    for(i = 0; i < len; i++) {
                         open(fls[i]), (sel = (aD = activeDocument).selection).selectAll(), sel.cut()
                         aD.close(SaveOptions.DONOTSAVECHANGES), activeDocument.paste()
                    }
               }
               else alert('There are no any .jpg files in chosen folder!')
          }
          else alert("There's no document opened or there are more than one!")
          

           

          Copy it to notepad and save as Script.jsx on your desktop. Note that saving files in notepad with other extension you have to take a name - with extension - to double quotes, so when saving you must use exacly this name: "Script.jsx". Copy it to your Presets/Scripts folder in your Photoshop folder. Then reopen Photoshop and you should find your action on File/Scripts list. Before you choose your item open/create new document. You can also make shortcut to that script, so you don't have each time to select it from File / Scripts list but just pressing for example F1 or other key you bound to.

           

          So instead of opening .pds file and then all .jpg files you open only .psd file and then run a script. By the script you choose a folder with your .jpe?g files you want to proecess. Each of them is going to open, be selected, cut, closed without saving and pasted to current .psd file. When the loop is finished Script.jsx stop working, so the error related to selecting next document when there is only one won't occur.

          • 2. Re: "next document" issue?
            isy26814400 Level 1

            thx for the script, i would use it, will be also cool.

             

            but the main problem is i cant get the error related to selecting next document , when only 1 file left opened. it just selects the same file and gives no errror. as i mentioned top.

             

            why this happens?

            • 3. Re: "next document" issue?
              Kukurykus Adobe Community Professional

              This is a bug I experienced in past when I didn't know how to script yet. That drove me crazy so I learned scripting to avoid it. I don't see other way than using a script to omit this situation that happens using actions. Operations are not perfect and very limited, scripts gives you oportunity to do what you want. That program I wrote was to help you with your problem. I guess you looked for something like it . It works and do exactly your action does, and even a bit more (without an error).

              • 4. Re: "next document" issue?
                JJMack Most Valuable Participant

                isy26814400  wrote

                 

                first of all, thanks to all of you who meant to help. and srry me for my bad english.

                 

                my problem is a little bit wierd, i have an action that works fine like,

                 

                select next document

                set selection

                cut

                close --> no

                paste

                 

                when i batch it, with my template psd file and jpegs opened, it gets the jpegs, cut them, and paste them in to the template as layers.

                 

                I do not understand why you need the select next document.  I feel it should nt be there. I would think the if you batched an action that simply did

                 

                set selection

                cut

                close --> nosave

                paste

                 

                All the documents that Batch opened would have the selection set cut to the clipboard the document would be closed but the data would not be cut out of it  because you use nosave in the action close step and the clipboard would then be pasted into the current document open in Photoshop.   You would end up with a document that has layers add that contains a selection of other documents that were opened selected copied closed and pasted by your action when batch ends you would be in and document the was the current document when you automated the batch process.  If the current document was opened from a psd files in the same folder as your jpeg when batch  open it batch should through an open error for the document was open in Photoshop if you ignore the error and continue the action would close nosave your current document you opened from that psd file. Make sure you do not have your template file mixed in with your jpeg files. Batch process all image files in a folder not just jpeg.  The Select next document should select the net document in photoshop for example your template.   Photoshop open document list is a ring when two documents are open next and previous become the same thing.

                • 5. Re: "next document" issue?
                  isy26814400 Level 1

                  i first open jpegs and batch the action, thats why i have a "select next document" command there, but your way is much better and simple. thx. i will use this.

                   

                  but still the select next document thing remains a mystery

                  • 6. Re: "next document" issue?
                    JJMack Most Valuable Participant

                    There is a warning about using next and previous in actions things can get mess up if document are added or removed in actions you need to be careful.  I would think your action would not work if the active document is your template document when you use automate batch or If  any one of you other open document is Photoshop active document when you use automate batch open doctments. When the next document is your template a selection will be made  the template will be closed . If you look at your action you see  it seem to me that you action is in effect removing the next document before batch has you process it. What is the next document may be the first document when batch process the last open document. You changing the number of open document on Batch.  Your batch seems to be cutting off its nose.

                     

                    ]If there are 10 documents open and every time the action proces a document a document is closed there will be 10 document closes.  10 open document 10 closed documents leaves no documents open.

                     

                     

                     

                    • 7. Re: "next document" issue?
                      isy26814400 Level 1

                      nah its really simple, and not about the action or batching. i can still click the "select next document" command when i just have 1 opened file in photoshop cs3. normally i mean by default, it needs to give an error like "the object next document can not be found". but now its not giving an error.

                      • 8. Re: "next document" issue?
                        JJMack Most Valuable Participant

                        I have use PS since PS 3 around 1993.  Photoshop's Action manger has always treaded its open document list like a ring.  When you get to the last entry in the open document list  when the action manager gets a next document it raps the the first and if fist document previous switches to the first. If one document is open as far as the action manager go it is next and previous. To record the select net and previous you need two open documents.    When played you can have 1 or more.  I edited these action with two open documents.  They play without error  if one or 100 documents are open in Photoshop.  There is no select first or last it basically from the active document where in the list you will switch to.  If you change the open document list you better know where in the list thing go.    Photoshop seems to insert new document into the list after the active document entry. Close seems to remove the current active document and Photoshop switches the the document precious in the list.

                         

                        You do not have a problem if you use script the open document list an array and is treated any way you wish to use it.  The Action managed treats the array as a ring.  Be it a one document, 2 documents, N documents the Action manager treats it as a ring. If your Photoshop Document list is ten long when you batch open documents Batch would most likely set a count of ten and start with Photoshop Active document.

                         

                        Action manager selection and document seems to be relative to the active document and the documents  the action recorder selected recording the action.  Here is a simple do nothing action the demonstrates that Select documents in actions is relative to some document there is also the notion of previous and next.

                        Capture.jpg

                        This action will also run without error with one document open.

                        • 9. Re: "next document" issue?
                          isy26814400 Level 1

                          "When played you can have 1 or more."

                          you are wrong because in one of my Pcs i have Ps CS2, and i get an error if i have only 1 document left.

                          and i have also another computer with Ps Cs2, and i dont get the error there.

                          and in my own PC i used to get the error, but now i can not. With PS CS3.

                          • 10. Re: "next document" issue?
                            JJMack Most Valuable Participant

                            isy26814400  wrote

                             

                            "When played you can have 1 or more."

                             

                            Was made in reference to the actions I just posted.  I had to reload my PC software and I chose not to re-install install CS2, CS3, CC, CC 2015, CC 2015.5 and CC 2017.  I just installed CS6, CC 2014 the version I use and CC 2018.

                             

                            Adobe states that if you are not careful recording actions that select documents you may have problems Selecting document is recorded relative to the current document.  You better know what you are doing actions can effect that change that relation.  Also Adobe's Action manager treats Photoshop Document array like its a ring.

                             

                            Look at this actions steps

                            Capture.jpg

                             

                            All version of Photoshop do behave the same way all versions have ave bugs and things are changed.

                            • 11. Re: "next document" issue?
                              Kukurykus Adobe Community Professional

                              Script can't control built-in loop of batch for opened documents. For ex. if there are FIVE opened documents and you select ONE of them, batch will process files from the earliest opened. No matter 1st, 3rd or 5th was active one. Anyway if you didn't want other way to solve this "bug", this time I made exactly you wanted, and wrote script doing that your action is supposed to do. The ultimate difference is that error won't occur!

                               

                              Save it as 'Script.jsx' the way I described before (pasting to notepad and taking name with extension to double quotes name blank), then copy it to your Presets / Scripts folder of your Photoshop (however Presets should be sufficient) and reopen Ps. Finally open at least two documents and create new action set or just in your current one start recording. Go to File / Scripts and click on: Script

                               

                              Now each time you dont have opened any document or there is only one nothing will happen. When you have two or more and you run your batch for Opened Files it processes all of them, stopping at last .psd document (with all previously opened jpgs in) without trying to select next document. What is very clever you can have chosen any document from opened ones before you start a batch and that will behave like only your psd was active one at beggining.

                               

                              if ((doc = documents).length > 1) {
                                   (sel = (jpg = activeDocument).selection).selectAll()
                                   sel.cut(), jpg.close(SaveOptions.DONOTSAVECHANGES)
                                   psd = activeDocument = doc[doc.length - 1], psd.paste()
                              }
                              

                               

                               

                              Regarding selecting next document when you are already on the last one (of 2 or more) I wrote other script that prevents from selecting next one (so first). It will select next document on the condition the current one is not the last.

                               

                              if ((len = (doc = documents).length)  > 1 && (aD = activeDocument) != doc[les = len - 1]) {
                                   for(i = les; i >= 0; i--) if (doc[i] == aD) {activeDocument = doc[i + 1]; break}
                              }
                              

                               

                               

                              Additionally I wrote similar script for selecting previous document. If that is first one it never selects last one, but if it is any other (as active one) then previous will be selected.

                               

                              if ((len = (doc = documents).length) > 1 && (aD = activeDocument) != doc[0]) {
                                   for(i = len - 1; i >= 0; i--) if (doc[i] == aD) {activeDocument = doc[i - 1]; break}
                              }
                              

                               

                               

                              Again you can save it as "Next.jsx" and "Previous.jsx" and copy to yout Presets folder, then reopen Photoshop and record them as action from File / Scripts. I used a loop starting from a last opened document as most possibly when you select previous / last document your active one in most cases will be (one of the) last one(s). If I made a loop starting from first document then work of script would be a little(?) longer if I guess there were about 70 documents opened.

                              • 12. Re: "next document" issue?
                                JJMack Most Valuable Participant

                                Here is what may work for you if you have a  version of Photoshop the has conditional actions or you download the conditional action script available one the web.

                                 

                                Your batch action is not good. You want to put  some selections of all open document but the first document into the first open doument as an added layer.  You may be able to do the with a conditional action. That plays your action with the select next document removed. if you batch it where your PSD Template document is the active document when you use File>Automate>Batch(open documents).

                                 

                                A single conditional step that plays your action. Does nothing for your layered PSD for the othes  none layered  docyments your action is played.   select, copy, close, paste.

                                • 13. Re: "next document" issue?
                                  isy26814400 Level 1

                                  Ok, at the end of the day we call it a "bug". i just wondered if it was some settings or else. anyways.

                                   

                                  Loooottttsssss of thx to you guys for your great help.

                                   

                                  this was my first time i asked a question in a forum, and you guys gave me hope.

                                   

                                  lots of thx again.

                                  • 14. Re: "next document" issue?
                                    Kukurykus Adobe Community Professional

                                    I wonder what you're going to use as workaround then?

                                    • 15. Re: "next document" issue?
                                      JJMack Most Valuable Participant

                                      isy26814400  wrote

                                       

                                      Ok, at the end of the day we call it a "bug".

                                      Not a bug it is a limitation actions have they could not use any logic unless you included some script step till Adobe added conditional steps to the action manager that can handle only a few document and layer conditions.  Your original action would be run once for the number of open documents and in each run there was a close step so if 10 document were open 10 documents would be closed. I would have thought the last paste step should have a error message  for no document should be open then.

                                       

                                      The conditional step does nothing to layered document that document will receives layer from selection of following none layer documents by the second action which select, copies, select previous document by closing the current document and paste in the clipboard.   You could populate  more than one layered documents by having layers document distributed in your open documents

                                       

                                      To do what you wanted to do required the use of some logic in the action.  The conditional step is the logic the was required.

                                       

                                      A single script can process the open documents and doe what you want.   With actions it requires two actions.   A conditional action that plays a second action for none layered documents.

                                       

                                      A script can populate a psd template with image  it places in, the psd, Resize the images for an areas, Position the images there and mask the images for the areas shape.

                                      ]