3 Replies Latest reply on Jun 23, 2016 10:41 AM by cbishop01

    Export Script help.

    cbishop01 Level 2

      What i'm trying to do is when a file is saved I want it be put in a specified folder.  and every time its saved i want it to add a number to the file name so it does not overwrite. and if possible work for all Open documents.  EX..

       

      DOCUMENT.PDF     Document1.PDF Document2.PDF   JOB1.PDF, JOB2.PDF, JOB3.PDF so on and so on.  (I'd only need about 8 different copies of but i'm not sure if you can restart the counting after it hits 8.  I'm gonna guess that is way too difficult. )  I thought the +(i+1) would keep counting and adding one but i'm missing a line somewhere.

      d = app.documents[0];  
          var i = 0, n = 8;
              preset1 = app.pdfExportPresets.itemByName("[Smallest File Size]");     
          if (!(preset1.isValid)){     
              exit();     
          }   
            
              mDocName = d.name.substr (0, d.name.lastIndexOf('.'));  
              mSourcePath = d.fullName.parent.toString();  
              mRootPath =mSourcePath.substr (0, mSourcePath.lastIndexOf('/Volumes/PPG/z-z MISC STUFF/INDESIGN SCRIPTS/Running CHanges/'));  
              mTargetPath=mRootPath.concat('/Volumes/PPG/z-z MISC STUFF/INDESIGN SCRIPTS/Running CHanges/');  
            while ( i,n ) {    
            mNamePrint = mTargetPath.concat(mDocName+(i+1),'.pdf');     
        i++;
        }
        if (!d.saved){     
              d.save;  
          }      
            d.exportFile(ExportFormat.PDF_TYPE,  File(mNamePrint), false, preset1);     
      }
      

       

       

      Thank you

      Chris Bishop

        • 1. Re: Export Script help.
          Johnwhite Level 1

          Hi,

           

          I think you should add a time temp at the tail.

           

          like XXXX-23-June-2225.pdf or XXXXX222502.pdf

           

          count to second

           

          so you will never write the old one.

           

          John

          1 person found this helpful
          • 2. Re: Export Script help.
            cbishop01 Level 2

            This is actually a better idea than what i was going to do.  I know how to make text variables do this but i do not know how to make the Files being saved do this.  Any ideas on this?

            • 3. Re: Export Script help.
              cbishop01 Level 2

              Never mind i figured it out.  Great SUggestion. Here's the code incase anyone wants to alter it or do the same.

               

              d = app.documents[0];    
                      var i = 0, n = 8;  
                          preset1 = app.pdfExportPresets.itemByName("[Smallest File Size]");       
                      if (!(preset1.isValid)){       
                          exit();       
                      }     
                          var now = new Date();
                          var timestamp =  two_digit(now.getHours()) + two_digit(now.getMinutes()) + two_digit(now.getSeconds());
                          mDocName = d.name.substr (0, d.name.lastIndexOf('.'));    
                          mSourcePath = d.fullName.parent.toString();    
                          mRootPath =mSourcePath.substr (0, mSourcePath.lastIndexOf('/Volumes/PPG/z-z MISC STUFF/INDESIGN SCRIPTS/Running CHanges/'));    
                          mTargetPath=mRootPath.concat('/Volumes/PPG/z-z MISC STUFF/INDESIGN SCRIPTS/Running CHanges/');    
                        while ( i<n ) {      
                        mNamePrint = mTargetPath.concat(mDocName + timestamp, '.pdf');       
                    i++;  
                    }  
                    if (!d.saved){       
                          d.save;    
                      }        
                        d.exportFile(ExportFormat.PDF_TYPE,  File(mNamePrint), false, preset1);       
                  } 
              
                  function two_digit(n) {
                     if (n < 10) {
                        return "0" + n.toString();
                  } else {
                     return n.toString();
                }
               }