1 Reply Latest reply on Nov 26, 2013 7:08 PM by RobertKyle

    Script Label insert into FileName

    BradRE

      Any help would be greatly appreciated!

       

      This is a portion of "PageExporterUtility5.0.js" that I'm tailoring to use at our workplace. Finding a simple description of how to use the "Script Label" is stumping me. How would you modify the following to work? My InDesign document has a Text Frame that I'd like to utilize the text contents in the filename. The text frame has been identified with a "Script Label" called "DOC_SIZE". An example of the text contents would be "18X24" (which is not the actual page size, just a rough description is needed).

       

      Current Base Name:

      816069-OHI-none-none.indd

       

      Export Name:

      816069_18X24_"Output Directory".eps

      w/ the Output Directory, I'd like to use the Folder Name, not the full path.

       

      These are the revalent sections of the script identifying the "outFile" Name.

       

      VAR SETUP

       

      for(currentDoc = 0; currentDoc < peuINFO.numDocsToExport; currentDoc++) {

          var tempENTRY = getNewTempENTRY();

          tempENTRY.theDoc = app.documents[currentDoc]

          tempENTRY.singlePage = (tempENTRY.theDoc.documentPreferences.pagesPerDocument==1)?true:false;

          tempENTRY.getOut = true;

          var baseName = (tempENTRY.theDoc.name.split(".ind"))[0];   

          var baseName = baseName.replace(/-OHI-none-none/g, "")

         

      MIDDLE

         

          else{

                  currentINFO.outfileName = currentINFO.baseName;

                  exportPage(currentINFO, PageRange.allPages);

         

         

      EXPORT PORTION

         

          case 2:

                  app.epsExportPreferences.pageRange = pgRange;

                      currentINFO.theDoc.exportFile(ExportFormat.epsType, (new File(outFile + ".eps")), false);

        • 1. Re: Script Label insert into FileName
          RobertKyle Level 2

          If the problem is getting the text contents of your labeled box, try something like this:

           

           

          var docsizeBoxes = new Array;

          for (var i = 0; i < app.activeWindow.activePage.textFrames.length; i++) {

              if (app.activeWindow.activePage.textFrames[i].label == "DOC_SIZE") {

                  docsizeBoxes.push(app.activeWindow.activePage.textFrames[i]);

                  break; }

          }

          var docsizeString = app.activeWindow.activePage.textFrames[i].contents;

           

          You should now be able to use docsizeString in parsing out the name of the output file.  This assumes that there will be one and only one text frame labeled "DOC_SIZE" on the active page. So you might need some error checking.

           

          If it were me, though, I'd just get the actual pageWidth and pageHeight from documentPreferences and use them. In my place, we don't have too many doc sizes to choose from.

          1 person found this helpful