4 Replies Latest reply on Jul 17, 2014 8:19 AM by Johnwhite

    How to use script to open a folder on desktop?

    Johnwhite Level 1

      Hi, everyone

       

      I want open a folder on desktop after gen PDF but error, can someone help me to fix it?


      var f = new Folder(“~/Desktop/Revised_PDF put in here/”); 
      f.create();

      var doc = app.documents; 
      app.findTextPreferences = null; 
      app.findTextPreferences.underline = true; 
      for(var i=0;i<doc.length;i++) 

              var found = doc[i].findText(); 
              var _pages = []; 
              for(var j=0;j<found.length;j++) 
              { 
                      var txfms = found[j].texts[0].parentTextFrames; 
                      for(var k=0;k<txfms.length;k++) 
                      { 
                              _pages.push(txfms[k].parentPage.name); 
                          } 
                  } 
              for(var j=0;j<_pages.length;j++) 
              { 
                      if(_pages[j] === _pages[j-1]) 
                      { 
                              _pages.splice(j,1); 
                          } 
                  } 
              if(_pages.length != 0) 
              { 
                      app.pdfExportPreferences.pageRange = _pages.toString(); 
                      doc[i].exportFile(ExportFormat.PDF_TYPE, new File(“~/Desktop/Revised_PDF put in here/” + doc[i].name.replace(/\.indd$/i,”.pdf”)), false);
                  } 
              _pages = []; 
          } 
      app.findTextPreferences = null;


      folder.open(“~/Desktop/Revised_PDF put in here/”)  // <-----------this line error

       

      John