7 Replies Latest reply on May 22, 2009 6:21 AM by Peter Kahrel

    [CS4] Saving without appending

    Giordano Galli Level 1

      Hello

       

      I'm stuck trying to replicate the result of a "Save as" with override, ie a save that will rebuild the document's file instead of appending to it. I'd appreciate your help on doing this using Javascript in InDesign CS4.

       

      Many thanks in advance.

       

       

      Giordano

        • 2. Re: [CS4] Saving without appending
          Giordano Galli Level 1

          Peter,

           

          thank you very much.

           

          So, am I correct saying that the following is what can be done using Javascript?

          1) save appending to the file: not possible

          2) save rebuilding the file: myDocument.save(File(myDocument.fullName))

          3) save to a new file and switch to it (same as "Save As" to a new file in the UI): myDocument.save(File(newFullName))

          4) save a copy and keep working with the original file (same as "Save a Copy" in the UI): not possible.

           

          I'm also wondering about the role of the 'forceSave' parameter of the 'save' method, which seems to make no difference in my scripts.

           

          Thanks for bearing with me. Besides being rather dense, I'm new to this stuff.

           

           

          Giordano

          • 3. Re: [CS4] Saving without appending
            Peter Kahrel Adobe Community Professional & MVP

            Giordano,

             

            "Rebuilding the document" may be a bit of an exaggeration: I think all it does is remove the document's undo history. A normal save adds to the document's undo history.If by "save appending to the file" you mean doing a normal save, then yes, you can do that: myDocument.save(). As to "Save as copy", I never use that, so I can't say.

             

            Peter

            • 4. Re: [CS4] Saving without appending
              Giordano Galli Level 1

              Peter,

               

              thank you so much, I didn't realize that the 'optional' in the documentation was about the 'to' parameter as a whole.

              To sum it all up:

              1) save appending to the file: myDocument.save()

              2) save rebuilding the file ("Save As" to the same file in the UI): myDocument.save(File(myDocument.fullName))

              3) save to a new file and switch to it (same as "Save As" to a new file in the UI): myDocument.save(File(newFullName))

              4) save a copy and keep working with the original file (same as "Save a Copy" in the UI): don't know, pending.

               

              Btw, with ”rebuilding the file" I mean the purging of unreferenced contents left over by previous standard (ie appending) save operations. Version 2) slims down the file the same way a UI "Save As" file does. The two files differ by a few bytes but a quick look in a hexadecimal editor seems to suggest they would almost stand a byte-by-byte comparison, so version 2) is most probably what I was after.

               

              Thank you a lot!

               

               

              Giordano

              • 5. Re: [CS4] Saving without appending
                Peter Kahrel Adobe Community Professional & MVP

                > 4) save a copy and keep working with the original file (same as "Save a Copy" in the UI): don't know, pending.

                 

                There's no direct script command for this I don't think, but you could do something like this (not tested):

                 

                n = String (app.documents[0].fullName);

                app.documents[0].save (File (n.replace (/\.indd$/, "-copy.indd")));

                app.documents[0].close();

                app.open (File (n));

                 

                Peter

                • 6. Re: [CS4] Saving without appending
                  AdobeScripts Level 3

                  ... or you can Save current file, and make copy of file - outside of InDesign

                   

                  robin

                   

                  www.adobescripts.co.uk

                  • 7. Re: [CS4] Saving without appending
                    Peter Kahrel Adobe Community Professional & MVP

                    >or you can Save current file, and make copy of file - outside of InDesign

                     

                    True:

                     

                    n = String (app.documents[0].fullName);
                    app.documents[0].save ();
                    File (n).copy (File (n.replace (/\.indd$/, "-copy.indd")));

                     

                    Peter