4 Replies Latest reply on Oct 22, 2017 3:20 AM by peters93073162

    Sort bookmarks alphabetically

    jay fresno Level 2

      I have several major bookmarks and quite a few subbookmarks below each of the major bookmarks, and the subbookmarks need to be alphabetical within their major bookmark category. I've not been able to find a feature in Acrobat Pro that will sort bookmarks. Does anyone on this forum know of such a feature or can point me to a script that will sort bookmarks?

        • 1. Re: Sort bookmarks alphabetically
          DimitriM Level 3

          Hi Jay,


          There is no feature built-in to Acrobat for doing this, but it can be accomplished with a script.  While I have not tried it myself, here is a link for a bookmark sorting script ( I think you would  have to pay a fee for it)-



          Hope this helps,



          WindJack Solutions



          • 2. Re: Sort bookmarks alphabetically
            Milo G Level 1

            I also need to do this.


            Here is a script to collect bookmarks into an array and then sort them alphabetically. The big part that is missing is how to then put them back in the document. Hopefully someone here can fill in this missing step.


            /* Gather Bookmarks into an Array */

            // Begin job setup

            if ( typeof global.bmArray == "undefined" ) {

            global.indexCnt = 0;

            global.bmFileCnt = 0;

            global.bmArray = new Array();


            global.bmFileCnt++; // Count files

            // Get the path of the file Acrobat has taken from the selected folder

            var path2file = this.path;

            // Regular expression that acquires the base name of file

            var re = /.*\/|\.pdf$/ig;

            // filename is the base name of the file Acrobat is working on

            var filename = path2file.replace(re,"");

            // If the title is available, use it for a bookmark, else use filename

            if ((this.info.Title==null) || (this.info.Title.replace(/\s/g,"")==""))

            var bmToFile = filename;


            var bmToFile = this.info.Title;

            global.bmArray[global.indexCnt] = [bmToFile,filename];



            //Alphabetize bookmark list in array

            function compare (a,b) { // Define a compare function

            if (a[0] < b[0] ) return -1;

            if (a[0] > b[0] ) return 1;

            return 0;



            • 3. Re: Sort bookmarks alphabetically
              bernst@fastline.com Level 1

              Milo, did you ever find a solution?

              • 4. Re: Sort bookmarks alphabetically

                You can use the following script to sort the top level bookmarks alphabeticaly



                Author: Peter Slezak

                Date: 21OCT2017

                Description: Sort Top level Bookmarks alphabeticaly.



                var bm = this.bookmarkRoot;

                var newBmPosition1 = -1;  // this will hold new bookmark position in the top level bookmarkroot


                // Iterate through each top level bookmark

                var ibmLength = bm.children.length;

                for (var i = 0; i < ibmLength; i++)


                   console.println("Beginning processing of Bookmark original number = " + i + ", bookmark name = " + bm.children[i].name + " ...");


                   for(var j=0; j<i; j++){

                      if(bm.children[i].name <= bm.children[j].name){


                         console.println("New Position Found = " + newBmPosition1 + " for " + bm.children[i].name);

                         break; // new position found, exit loop


                      else {  console.println("No Match Found in this loop - " + j + ", " + bm.children[i].name);   }



                   if (newBmPosition1>=0) {

                      bm.insertChild(bm.children[i], newBmPosition1);



                   else {console.println("No Match Found keep on the original position, " + bm.children[i].name);}

                   console.println("... End processing of Bookmark original number = " + i + ", bookmark name = " + bm.children[i].name);