26 Replies Latest reply on Aug 27, 2016 12:53 PM by Obi-wan Kenobi

    Index – Add All in a name list ---> InDesign CC

    mterraza

      Hello, I'm trying to do an index in InDesign with a list of 1,000 names, some of them should be included in the normal way, as we read, and part starting with the last name. When I use the shortcut "Cmd + Option + Shift +]" or "Cmd + Option + Shift + [" InDesign inserts the page reference only the selected name, without a search throughout the publication. I need all the names on the list have an "Add All" in the publication. I'm having to do the insert one by one and then having to change and manually reverse the "topic" each name by name. Does anyone know another possibility?

        • 1. Re: Index – Add All in a name list ---> InDesign CC
          Obi-wan Kenobi Adobe Community Professional

          Hi,

           

          By curiosity, could you tell us how many time you think you need to spend to do it manually! Thanks!

           

          (^/)

          • 2. Re: Index – Add All in a name list ---> InDesign CC
            mterraza Level 1

            Well, actually I would like to do this as soon as possible, but as I have to manually do I believe it will take a very considerable time, I imagine that two or three days. But I'm not sure if I can in that time. We will see. lol

            • 3. Re: Index – Add All in a name list ---> InDesign CC
              Obi-wan Kenobi Adobe Community Professional

              Aha! That doesn't help you! 

              • 4. Re: Index – Add All in a name list ---> InDesign CC
                Obi-wan Kenobi Adobe Community Professional

                Can you give us clear samples? 

                • 5. Re: Index – Add All in a name list ---> InDesign CC
                  Marie_D Level 1

                  Open the index palette. Select the name you want to index in your InDesign file, create a new entry (either via the icon at the bottom of the Index palette or by pressing ctrl+7 (pc)), adjust the entry in the dialogue box to how you want it to appear in the index and select 'add all'. All instances of the selected text in the document will be added to the index.

                  • 6. Re: Index – Add All in a name list ---> InDesign CC
                    Obi-wan Kenobi Adobe Community Professional

                    Yep! … and do it 1,000 times! 

                    [but the tip is truly interesting to be said!]

                    • 7. Re: Index – Add All in a name list ---> InDesign CC
                      mterraza Level 1

                      @Marie_D ––> Yes, I know that. But I need to do it a thousand times by hand, that is what I wanted to avoid. I wish the InDesign had a tool that would add all with a whole list and then another tool that could provide the name sorted by last name or by name. I will not be able to do differently, at least for now. I hope that Adobe can improve this important tool. Thank you.

                      Obi-wan Kenobi

                      • 9. Re: Index – Add All in a name list ---> InDesign CC
                        Obi-wan Kenobi Adobe Community Professional

                        Sample:

                         

                        in Text: Obi-wan Kenobi

                        in Index: Kenobi, Obi-wan

                         

                        in Text: light-saber

                        in Index: entry level 1 = weapon ; entry level 2 = Light-saber

                         

                        ………

                         

                        (^/) 

                        • 10. Re: Index – Add All in a name list ---> InDesign CC
                          mterraza Level 1

                          Yes, that's it. But in my work I will not need to add text at level 2.

                          Correct!

                          Sample:

                           

                          in Text: Obi-wan Kenobi

                          in Index: Kenobi, Obi-wan

                           

                          All names must enter the Index and get your references on every page they are. {Add All}

                          And after that it is necessary that all names begin with the last name as the example given by you and remain with all its pages references.

                          Like this:

                           

                          {before}

                          Américo Fernandes • 73

                          Ana Cecília Tavares • 147, 153, 194, 265

                          Anacleto de Medeiros • 241

                          Anadir Rodrigues • 237

                           

                          {after}

                          Fernandes, Américo • 73

                          Tavares, Ana Cecília • 147, 153, 194, 265

                          Medeiros, Anacleto de • 241

                          Rodrigues, Anadir • 237

                          • 11. Re: Index – Add All in a name list ---> InDesign CC
                            Obi-wan Kenobi Adobe Community Professional

                            Have you a list of names or just in the body text?

                            • 12. Re: Index – Add All in a name list ---> InDesign CC
                              mterraza Level 1

                              Yes, I have a list of names which I separated the names that the end will be in the normal order, and another list of names that will be the order by surnames.

                              Obi-wan Kenobi

                              • 13. Re: Index – Add All in a name list ---> InDesign CC
                                Obi-wan Kenobi Adobe Community Professional

                                … So:

                                In the first list, you have: Obi-wan Kenobi, that is equal in the index

                                In the second list: Darth Vador, that will become: Vador, Darth in the index

                                 

                                Right?

                                 

                                Your lists are Word or .txt files?

                                • 14. Re: Index – Add All in a name list ---> InDesign CC
                                  mterraza Level 1

                                  Yes, that's it.

                                  My lists are Word, but I can go to Text file, or even Pages from Apple, doesn't matter, because it is already listed and I can copy and paste anywhere, just can not do is lose the page references in InDesign, because if need to change something in the book is necessary that the "Index" keep the page references in the correct locations.

                                  • 15. Re: Index – Add All in a name list ---> InDesign CC
                                    Obi-wan Kenobi Adobe Community Professional

                                    Humm!…

                                     

                                    Confirm to me! Your 2 list look like:

                                     

                                    Anakin Skywalker

                                    Han Solo

                                    Leia Organa

                                    Luke Skywalker

                                    Obi-wan Kenobi

                                    Padmé Amidala

                                    Yoda

                                     

                                    Without page numbers!

                                     

                                    Right?

                                     

                                    (^/)

                                    • 17. Re: Index – Add All in a name list ---> InDesign CC
                                      Obi-wan Kenobi Adobe Community Professional

                                      As BarbBinder said about me, "… does anyone ever know what Obi-Wan is doing?"

                                       

                                      Playing with a list of names [some friends!]:

                                       

                                      Capture d’écran 2016-08-19 à 23.32.42.png

                                       

                                      … a proclamation text:

                                       

                                      Capture d’écran 2016-08-19 à 23.33.50.png

                                       

                                      … and the help of The Force:

                                       

                                      Capture d’écran 2016-08-19 à 23.47.35.png

                                       

                                      MTFBWY! … even if its dark side may be attractive!

                                       

                                      // It took me some minutes to do it, surely much more to explain it to you and give you the good tools to play it [4 scripts, Multi/Find-Change and several regex]!

                                      Play with 7 index entries or 10,000 will be equal: you don't even have time to sit down! 

                                      Later!

                                       

                                      (^/) 

                                      • 18. Re: Index – Add All in a name list ---> InDesign CC
                                        mterraza Level 1

                                        WoW!

                                         

                                        May the force be with you!

                                         

                                        TY!

                                         

                                        Obi-wan Kenobi

                                        • 19. Re: Index – Add All in a name list ---> InDesign CC
                                          Obi-wan Kenobi Adobe Community Professional

                                          In fact, The Force makes it so simple!  (^/)

                                           

                                          Open the main InDesign file:

                                           

                                          Capture d’écran 2016-08-20 à 10.40.41.png

                                           

                                          No index!

                                           

                                          Open the first list InDesign file [ First/Last names to be inversed ], select the text frame:

                                           

                                          Capture d’écran 2016-08-20 à 10.46.54.png

                                           

                                          … and launch "Index_FromList_PeterKahrel.jsx" (modified by me):

                                           

                                          See below.

                                           

                                          [ the first list file is automatically closed! ] … This script creates the index entries from the first list.

                                          [ A first lightsaber stab that only takes a second! (^/) ]

                                           

                                          Capture d’écran 2016-08-20 à 10.47.11.png

                                           

                                           

                                          … Then launch "Index_InversionFirstLastNames_0012_MichelAllio.jsx":

                                           

                                          See below.

                                           

                                          This script will inverse the first/last names.

                                          [ A second lightsaber stab that only takes a new second too! (^/) ]

                                           

                                          Capture d’écran 2016-08-20 à 10.47.42.png

                                           

                                          Play the game again with the second list [the main file is always open]:

                                          Open the second list InDesign file, select the text frame:

                                           

                                          Capture d’écran 2016-08-20 à 10.48.03.png

                                           

                                          …  and launch "Index_FromList_PeterKahrel.jsx" another time :

                                           

                                          Capture d’écran 2016-08-20 à 10.48.45.png

                                           

                                          [ the second list file is automatically closed! ] … This script creates the index entries from this second list.

                                          [ A third lightsaber stab and always a second! (^/) ]

                                           

                                          Done in just 3 seconds! Join The Force!

                                           

                                          MTFBWY!  (^/)

                                           

                                          ---------------------------------------------------------------

                                           

                                          "Index_FromList_PeterKahrel.jsx" (modified by me):

                                           

                                          //DESCRIPTION: Index from word list
                                          // Peter Kahrel -- www.kahrel.plus.com
                                          
                                          
                                          /*
                                            16 Nov. 2011: fixed bug that chopped off word-final s
                                          */
                                          
                                          
                                          #target indesign
                                          
                                          
                                          // List the paragraph styles to be included, using the first three
                                          // characters of their name (case-sensitive), and prefixed with "|".
                                          // Use "" to ignore this and include all paragraph styles
                                          
                                          
                                          paragraph_styles = "";
                                          //paragraph_styles = "|def|sec";
                                          
                                          
                                          // 'true': search documents case-sensitively,
                                          // 'false': ignore case
                                          
                                          
                                          case_sensitive = true;
                                          
                                          
                                          // Replace index?
                                          
                                          
                                          replace_index = true;
                                          
                                          
                                          
                                          
                                          /*--------------------------------------------------------------------------
                                          
                                          
                                          Create word-list. To create separate indexes,
                                          prefix items with any of the symbols £ % & @.
                                          Open all files to be concordanced, then select frame
                                          (or insertion point) in document with concordance file.
                                          
                                          
                                          ------------------------------------------------------------------------------*/
                                          
                                          
                                          index_from_list ();
                                          
                                          
                                          
                                          
                                          function index_from_list ()
                                            {
                                            environment_check ();
                                            find_options (); //set various options for Find
                                            var list = get_list (app.activeDocument);
                                            app.activeDocument.close (SaveOptions.yes);
                                            displ = init_progress ();
                                            index_documents (list, displ);
                                            }
                                          
                                          
                                          function index_documents (word_list, displ)
                                            {
                                            for (var i = app.documents.length-1; i > -1; i--)
                                            {
                                            var doc = app.documents[i];
                                            displ[0].text = doc.name;
                                          // if (replace_index == true)  // ----------------------------------------------------------   Modification Original Script by Michel Allio
                                          // try {doc.indexes[0].topics.everyItem().remove()} catch (_){}; // ------------------   Modification Original Script by Michel Allio
                                            if (doc.indexes.length == 0)
                                            doc.indexes.add ();
                                            for (var j = 0; j < word_list.length; j++)
                                            {
                                            displ[1].value = j;
                                            // split word-list entry into item to search and item to use for index
                                            var search_item = get_search_item (word_list[j]);
                                            try
                                            {
                                            var new_topic = doc.indexes[0].topics.add (word_list[j]);
                                            //delete prefixed symbol, if any
                                            app.findGrepPreferences.findWhat = search_item;
                                            var found = doc.findGrep();
                                            for (var k = found.length-1; k > -1; k--)
                                            {
                                            try
                                            {
                                            // if the found string's parent paragraph style name begins with d, q, or n
                                            if (style_ok (found[k]))
                                            new_topic.pageReferences.add (found[k], PageReferenceType.currentPage);
                                            } catch(_) {/* not interested in errors */}
                                            } // for (k
                                            } catch(_){}
                                            } // for (j
                                            doc.save ();
                                          // doc.close (); // ------------------   Modification Original Script by Michel Allio
                                            }
                                            }
                                          
                                          
                                          // Take an item from the word list and create a search item:
                                          // split word-list item on comma. If that fails,
                                          // split on parenthesis. If that fails too, return the whole item.
                                          // Wrap string in word-boundary markers and 
                                          // prefix the case-insensitive code, if necessary.
                                          
                                          
                                          function get_search_item (s)
                                            {
                                            // delete prefixed symbol
                                            s = s.replace(/^[£%&@]/, "");
                                            // delete anything from comma or parenthesis
                                            s = s.replace (/\s?[,(].+$/, "");
                                            // add word boundaries
                                            s = "\\b" + s  + "\\b";
                                            if (case_sensitive == false)
                                            s = "(?i)" + s;
                                            return s
                                            }
                                          
                                          
                                          
                                          
                                          function style_ok (w)
                                            {
                                            return ((paragraph_styles == "") || 
                                            (paragraph_styles.search (w.appliedParagraphStyle.name.slice (0,3)) > 0))
                                            }
                                          
                                          
                                          
                                          
                                          function get_list (doc)
                                            {
                                            // Remove trailing spaces
                                            app.findGrepPreferences.findWhat = "\\s+$";
                                            app.changeGrepPreferences.changeTo = "";
                                            app.activeDocument.changeGrep ();
                                            // Remove serial spaces
                                            app.findGrepPreferences.findWhat = "  +";
                                            app.changeGrepPreferences.changeTo = " "
                                            app.activeDocument.changeGrep();
                                            return app.selection[0].parentStory.contents.split ('\r');
                                            }
                                          
                                          
                                          
                                          
                                          function environment_check ()
                                            {
                                            if (parseInt (app.version) < 5)
                                            errorM ('The script runs only in InDesign CS3 and later versions.');
                                            if (app.documents == 0)
                                            errorM ('Open a word list and \rthe documents to be indexed.')
                                            if (app.documents.length == 1)
                                            errorM ('Open the documents to be indexed.');
                                            if (app.selection.length == 0)
                                            errorM ('Select a text frame in the word list.');
                                            if ('TextFrameInsertionPoint'.search (app.selection[0].constructor.name) < 0)
                                            errorM ('Select a text frame in the word list.');
                                            }
                                          
                                          
                                          function find_options ()
                                            {
                                            app.findGrepPreferences = app.changeGrepPreferences = null;
                                            app.findChangeGrepOptions.includeLockedLayersForFind = false;
                                            app.findChangeGrepOptions.includeLockedStoriesForFind = false;
                                            app.findChangeGrepOptions.includeHiddenLayers = true;
                                            app.findChangeGrepOptions.includeMasterPages = false;
                                            app.findChangeGrepOptions.includeFootnotes = true;
                                            }
                                          
                                          
                                          
                                          
                                          function errorM (m)
                                            {alert (m); exit()}
                                          
                                          
                                          
                                          
                                          function init_progress ()
                                            {
                                            index_progress = new Window ('palette', 'Concordance' );
                                            index_progress.alignChildren = ['left', 'top'];
                                            fname = index_progress.add ('statictext', undefined, '------');
                                            fname.characters = 40;
                                            pbar = index_progress.add ('progressbar', undefined, 1, 50);
                                            pbar.preferredSize = [270,20];
                                            index_progress.show();
                                            return [fname,pbar];
                                            }
                                          

                                           

                                           

                                          "Index_InversionFirstLastNames_0012_MichelAllio.jsx":

                                           

                                          (function () {  
                                            if (app.documents[0].indexes.length > 0) {  
                                               var topics = app.documents[0].indexes[0].allTopics;  
                                               for (var i = topics.length-1; i >= 0; i--) {  
                                                    var n = topics[i].name  
                                                    if (/^([A-ZÉ]([A-ZÉa-zé_.-])+)\s(([A-ZÉa-zé-]\s?)+)$/.test(n)) {  
                                                        topics[i].name = n.replace (/([A-ZÉ]([A-ZÉa-zé_.-])+)\s([A-ZÉ]([A-ZÉa-zé_.-])+)/, '$3, $1 ');  
                                                       }  
                                                    if (/(.*_.*)+$/.test(n)) {  
                                                        topics[i].name = n.replace (/_/, ' ');  
                                                       }  
                                                  }  
                                              }  
                                          }());  
                                          
                                          1 person found this helpful
                                          • 20. Re: Index – Add All in a name list ---> InDesign CC
                                            mterraza Level 1

                                            Fantastic! I've never worked with scripts before, how I should proceed to save the data information and save it as a script file on InDesing? How do I open the file for it to work in InDesign. What I mean is: how do I do to turn your information into a file and as I lay in InDesign? Because I did not find here any attached file, it is attached? Thank you very much. You are the best!

                                            • 21. Re: Index – Add All in a name list ---> InDesign CC
                                              Salah Fadlabi Level 5

                                              how I should proceed to save the data information and save it as a script file on InDesing?

                                              http://indesignsecrets.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-o r-blog-post.php

                                              1 person found this helpful
                                              • 22. Re: Index – Add All in a name list ---> InDesign CC
                                                mterraza Level 1

                                                Hi @Salah Fadlabi

                                                Great, thank you so much!

                                                • 23. Re: Index – Add All in a name list ---> InDesign CC
                                                  mterraza Level 1

                                                  I want to thank everyone who contributed and especially to the Obi-wan Kenobi

                                                  Thank you so much!

                                                  MTFBWY!  ;-)

                                                  • 24. Re: Index – Add All in a name list ---> InDesign CC
                                                    mterraza Level 1

                                                    I think I managed to do. See if I did right, I opened a document new ID, put it to my list and I made a run script, then the program opened a window for me to choose the file ID book and I chose, then everything went correctly. That's right?

                                                    Obi-wan Kenobi

                                                    • 25. Re: Index – Add All in a name list ---> InDesign CC
                                                      mterraza Level 1

                                                      Hello Obi-wan Kenobi, I would like to give feedback of the script that you did and helped me a lot. The script used to enter the names in the normal way it worked perfectly, but the script makes reversing the name to the surname unfortunately had several flaws. Some have reversed the middle name, and not the surname, other names were not reversed. I'm saying this in case you have an interest in improving your fantastic creation. I had to individually solve these cases, but the scripts have helped me a lot. Thank you.

                                                      • 26. Re: Index – Add All in a name list ---> InDesign CC
                                                        Obi-wan Kenobi Adobe Community Professional

                                                        Hi Marcelo,

                                                         

                                                        The behavior of my script is totally normal, based on a grep code that basically just inverts first name and last name!

                                                        If you want more as Leonardo da Vinci, you need more complex codes! … But it would cost you much more! 

                                                        In any case, it was quite doable!!

                                                         

                                                        (^/)