4 Replies Latest reply on Apr 18, 2012 2:01 AM by Evilia_77

    Script to List all of the Top/Parent Bookmarks not the Sub Bookmarks

    Jo_2005 Level 1

      Hello,

       

      Can anyone please advise how to modify the following script which lists the entire bookmark tree to instead list all of the top level bookmarks and not the sub bookmarks?

       

      This is the script I have used which lists all of the bookmarks.

       

      /* List all Bookmarks */
      /* Recursively work through bookmark tree  */
      function PrintBookmarks(bm, nLevel)
      {
          if (nLevel != 0) { // don't print the root
              bmReport.absIndent=bmTab*(nLevel-1);
      bm.execute();
              bmReport.writeText("(page# "+(bm.doc.pageNum +1)+ ") "+bm.name);

                }       
          if (bm.children != null)
                for (var i = 0; i < bm.children.length; i++)
                  PrintBookmarks(bm.children[i], nLevel + 1);                          
      }
      bmTab = 20;
      bmReport = new Report();
      bmReport.size = 2;
      bmReport.writeText(this.title);
      bmReport.writeText(" ");
      bmReport.size = 1.5;
      bmReport.writeText("Listing of Bookmarks");
      bmReport.writeText(" ");
      bmReport.size = 1;
      PrintBookmarks(this.bookmarkRoot, 0);
      global.bmRep = bmReport;  // make global
      global.wrtDoc = app.setInterval(
          'try {'
          +'       reportDoc = global.bmRep.open("Listing of Bookmarks");'
          +'       console.println("Executed Report.open");'
          +'       app.clearInterval(global.wrtDoc);'
          +'       delete global.wrtDoc;'
          +'       console.println("Executed App.clearInterval");'
          +'       reportDoc.info.title = "Bookmark Listings";'
          +'       reportDoc.info.Author = "List Bookmark Sequence";'
          +'} catch (e) {console.println("Waiting...: " + e);}'
          , 100);

       

      Any help will be most appreciated.