3 Replies Latest reply on Oct 1, 2013 2:12 AM by csm_phil

    Run Script for opened files

    jocstone_me Level 1

      Hi,

      I once got a script by this thread (http://forums.adobe.com/thread/962689)

      That script gets Indesign files from a specific folder,

      now I want to change this script, so it can be used for allready opened Indesign files.

       

      Below is the original script (with huge thanks to Muppet Mark)

       

      #target indesign

       

      function exportFolder() {

       

                 var i, inFolder, idFiles, doc, offSet, pdfPre, pdfFile;

       

                 inFolder = Folder.selectDialog( 'Where\'s the folder of ID files?' );

       

                 if ( inFolder == null ) { return };

       

                idFiles = inFolder.getFiles( '*.indd' );

       

                for ( i = 0; i < idFiles.length; i++ ) {

       

                          doc = app.open( idFiles[i] );

       

                          offSet = doc.documentPreferences.documentBleedTopOffset;

                         

                          if ( offSet == 0 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 3 mm snit + slug' ) };

                         

                          if ( offSet == 3 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 3 mm snit + slug' ) };

       

                          if ( offSet == 5 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 5 mm snit + slug' ) };

       

                          if ( offSet == 10 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 10 mm snit + slug' ) };

                         

                          if ( offSet == 11 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 11 mm snit + slug' ) };

                         

                          if ( offSet == 12 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 12 mm snit + slug' ) };

                         

                          if ( offSet == 13 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 13 mm snit + slug' ) };

                         

                          if ( offSet == 14 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 14 mm snit + slug' ) };

       

                          if ( offSet == 15 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 15 mm snit + slug' ) };

                         

                          if ( offSet == 16 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 16 mm snit + slug' ) };

                         

                          if ( offSet == 17) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 17 mm snit + slug' ) };

                         

                          if ( offSet == 18 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 18 mm snit + slug' ) };

                         

                          if ( offSet == 19 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 19 mm snit + slug' ) };

                         

                          if ( offSet == 20 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 20 mm snit + slug' ) };

       

                          pdfFile = File( doc.fullName.toString().replace( '.indd', '.pdf' ) );

       

                          doc.exportFile( ExportFormat.pdfType, pdfFile, false, pdfPre, '', false );

       

                          doc.close( SaveOptions.NO );

       

                };

       

      };

       

      exportFolder();

        • 1. Re: Run Script for opened files
          csm_phil Level 4

          Hi jocstone_me,

           

          I modified your JS code, Please try the below code its working.

           

           

          #target indesign
          function exportFolder() {
          var i, inFolder, idFiles, doc, offSet, pdfPre, pdfFile;
          inFolder = Folder.selectDialog( 'Where to save the InDesign files?');
          if ( inFolder == null ) { return };
          
          idFiles = app.documents.length;
          for ( i = 0; i < idFiles; i++ ) {
              doc = app.documents[i];
              doc = app.activeDocument;
              offSet = doc.documentPreferences.documentBleedTopOffset;
              if ( offSet == 0 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 3 mm snit + slug' ) };
              if ( offSet == 3 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 3 mm snit + slug' ) };
              if ( offSet == 5 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 5 mm snit + slug' ) };
              if ( offSet == 10 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 10 mm snit + slug' ) };
              if ( offSet == 11 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 11 mm snit + slug' ) };
              if ( offSet == 12 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 12 mm snit + slug' ) };
              if ( offSet == 13 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 13 mm snit + slug' ) };
              if ( offSet == 14 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 14 mm snit + slug' ) };
              if ( offSet == 15 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 15 mm snit + slug' ) };
              if ( offSet == 16 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 16 mm snit + slug' ) };
              if ( offSet == 17) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 17 mm snit + slug' ) };
              if ( offSet == 18 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 18 mm snit + slug' ) };
              if ( offSet == 19 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 19 mm snit + slug' ) };
              if ( offSet == 20 ) { pdfPre = app.pdfExportPresets.itemByName( 'LANNOO 20 mm snit + slug' ) };
              pdfFile = File(inFolder+"/"+doc.name.toString().replace( '.indd', '.pdf' ) );
              doc.exportFile( ExportFormat.pdfType, pdfFile, false, pdfPre, '', false );
              doc.close( SaveOptions.NO );
              };
          };
          exportFolder();
          

           

           

          thx,

          csm_phil

          • 2. Re: Run Script for opened files
            jocstone_me Level 1

            Hi Phil, this works great!

             

            I was just a little confused with the dialog "Where to save the Indesign files?", but I figured out this should be "Where to save the PDF files?"

             

            So it does what is should, and I'm a happy person!

             

            Thanks again Phil

            • 3. Re: Run Script for opened files
              csm_phil Level 4

              Hi jocstone_me,

               

              Yes, I agree the typo errors, Thanks for highlighted this!

               

              thx,

              csm_phil