TOC and multiple identical entries
Learn / Forums / General InDesign Topics / TOC and multiple identical entries
- This topic has 24 replies, 7 voices, and was last updated 7 years, 9 months ago by Ari Singer.
-
AuthorPosts
-
-
May 5, 2016 at 7:11 am #84626Riccardo RiguzziMember
Hi all,
I’m working on a catalogue and I need to place, at the end of the document, a TOC with all the product codes that appear inside my indesign document.
The problem is I have the same code (es: 5022030014) on different pages, and of course, when I create my TOC, indesign lists the entries like:
5022030014…. 1
5022030014…. 22
5022030014…. 24
5022030014…. 33
etc…but what I want is something like this:
5022030014…. 1, 22, 24, 33What should I do?
Thanks a lot! -
May 5, 2016 at 8:38 am #84630Kelly VaughnParticipant
That’s seems like more of an index. You could probably do a grep search for the duplicates and remove them. But if it’s not too big of a catalog, it my be easier to just do it manually. But I am not a grep person. Perhaps the grep users will have a better idea.
-
May 5, 2016 at 8:48 am #84632David BlatnerKeymaster
This is for an index, but I wonder if it (or some other Kahrel script) would work: https://www.kahrel.plus.com/indesign/index_update.html
-
May 5, 2016 at 8:55 am #84633Riccardo RiguzziMember
thx for the advice, the thing is it’s a quite big catalogue (322 page, over 12.000 product codes, I’m not joking).
The previous designer used to use Xpress, create an index/toc using a character style as a parameter (not a paragraph style, and it was quite useful because she could have codes inside paragraphs lines), save the list of entries (every line had a code and its page number) as a RTF file and then use a script to collapse all the entries in a style she wanted (code n,n,n,n)I’m trying to find a way inside indesign and I would like to avoid to add every entry as a topic for and index.
Right now I found a way, similar to the one of my ex colleague, that is:
1) from my catalogue file, create a TOC with no page number to have all my entries in a list
2)copy the list into a new indesign document. save it.
3) use this script https://www.kahrel.plus.com/indesign/index_from_wordlist.html to add all the entries of the list to my catalogue topics
4) create an index.But I’m wondering if there is an easier way :)
The other difficulty is to be able to have the codes “free” inside the paragraph, so it would be great to be able to use a character style and not a paragraph style to create the codes entries, but I cannot create a TOC using a character style as a parameter…
-
May 5, 2016 at 10:48 pm #84644Marie DohertyMember
This script might suit your needs. It creates an index based on character styles: https://www.indiscripts.com/category/projects/IndexMatic
-
May 8, 2016 at 12:00 pm #84659Ari SingerMember
You can leave everything the way you want and use the following cleanup FindChangeList.txt script support to clean up the file in one fell swoop.
If you’re not familiar with FindChangebyList check it this article, it’s very simple.
Just replace the default FindChanngelist text support file contents with the following lines:
grep {findWhat:"(?s)(\\b\\d{8,}\\b)(.+?)(\\d{1,3})(.+?)(\\1(.+?)(\\d{1,3})(.+?))+"} {changeTo: "", appliedFont:"Times New Roman", fontStyle:"Italic"} {searchBackwards:false, includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, kanaSensitive:true, widthSensitive:true} //Find duplicates and apply temporary formatting grep {findWhat:"(\\d{1,3})(\\r)", appliedFont:"Times New Roman", fontStyle:"Italic"} {changeTo: "$1,"} {searchBackwards:false, includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, kanaSensitive:true, widthSensitive:true} //Delete returns & add commas grep {findWhat:"(?<=,)(\\d{8,}).+?(?=\\d)", appliedFont:"Times New Roman", fontStyle:"Italic"} {changeTo: ""} {searchBackwards:false, includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, kanaSensitive:true, widthSensitive:true} //Delete all unnecessary characters grep {findWhat:",$", appliedFont:"Times New Roman", fontStyle:"Italic"} {changeTo: ""} {searchBackwards:false, includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, kanaSensitive:true, widthSensitive:true} //Delete last comma
What this basically does is find any instances of duplicate entries, apply a temporary font (Times New Roman, Italic), then find any text with said formatting and delete any returns and replace with commas. Then delete all unnecessary text and delete the last comma.
Just Note: When the script is done, there will be local Times New Roman formatting on all the fixed instances so make sure to select all text and press on the Clear Overrides in Selection button on the bottom of the paragraph styles panel.
-
May 8, 2016 at 10:52 pm #84661Riccardo RiguzziMember
Thx a lot!
UPDATE:
I don’t know why but I get an error when I try to run the script.
I’ve copied your code and pasted it as shown in the post you linked (and here is a link to a screenshot of my script copy/paste: https://drive.google.com/open?id=0B0oislVwKoh-NHFsYUZHS2dNN00)
And here is the error I get: https://drive.google.com/open?id=0B0oislVwKoh-eE1GdmlzNW9hZHcWhat am I doing wrong?
-
May 9, 2016 at 6:42 am #84670Ari SingerMember
Thanks for supplying the screenshot. You’ve made the same mistake I made when I used the FindChangebyList the first time…
There are two files: one is
FindChangeByList.jsx
that is found in the Scripts panel and you should not touch this one! If you alter this jsx file nothing will work. Before you do anything, you have to make sure that the jsx file is back to the original. If you didn’t backup the original file then you can find it here. Just download it, extract it, and paste and replace in the original position.The other file, and the one you do replace the contents of is the
FindChangeList.txt
file found in theFindChangeSupport
subfolder in the scripts panel. You open that file and replace the contents with the text I provided.But it’s also a good idea to save a backup of the original .txt file as well. If you have any questions, don’t hesitate.
-
-
June 30, 2016 at 7:40 am #86174Valentin OreillerMember
Hi,
I’m having the same issue but my entries are roman letters and digit, I was wondering how to change the expression to make it works.
An example on entry would be : STEINEMANN – Arpentage et marquage 585.Thanks a lot!
-
June 30, 2016 at 7:59 am #86176Ari SingerMember
I can only alter the script if I have an idea of what you’re looking for. Give me a couple of examples (or a screenshot) so I can figure it out.
-
-
June 30, 2016 at 8:14 am #86177Valentin OreillerMember
Hi,
Here a screen shot https://www.dropbox.com/s/thjsg2fepzvsewx/example.png?dl=0, I’d like for example to have just one entry for SIKA, etc.
Thank you very much!
-
June 30, 2016 at 11:52 am #86180Ari SingerMember
This time I made it easier. It’s just a regular script that you have to execute, it doesn’t require the FindChangebyList script.
Read here on how to save the script.
I’m not sure if it works as expected, so please let me know.
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Fix Duplicate TOC Entries"); function main() { var myDoc = app.activeDocument; cleanPrefs(); app.findGrepPreferences.findWhat = "(?s)(\\b\\w+?\\b)(\\s+?)(\\d{1,3})(\\s+?)(\\1(.+?)(\\d{1,3})(.+?))+"; var foundText = myDoc.findGrep(); for (var i = foundText.length - 1; i >= 0; i--) { var curEntry = foundText[i]; app.findGrepPreferences.findWhat = "\\r(?=.)"; app.changeGrepPreferences.changeTo = ",\\s"; curEntry.changeGrep(); app.findGrepPreferences.findWhat = "(?<=,\\s)(\\w+?).+?(?=\\d)"; app.changeGrepPreferences.changeTo = ""; curEntry.changeGrep(); } cleanPrefs(); } function cleanPrefs() { app.findGrepPreferences = app.changeGrepPreferences = null; }
-
June 30, 2016 at 11:11 pm #86189Valentin OreillerMember
Hi,
Thank you for your quick answer! I tried the script but I had the following error message : https://www.dropbox.com/s/2yvpii8nxjdvrkz/error_message.png?dl=0
So I tried to replace the expression in the FindChangedlist text support by the expression in your script. The first line of the text file is :
grep {findWhat:”(?s)(\\b\\w+?\\b)(\\s+?)(\\d{1,3})(\\s+?)(\\1(.+?)(\\d{1,3})(.+?))+”} {changeTo: “”, appliedFont:”Times New Roman”, fontStyle:”Italic”} {searchBackwards:false, includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:false, kanaSensitive:true, widthSensitive:true} //Find duplicates and apply temporary formatting
I let the remaining lines the same as you posted before. The output from this operation was https://www.dropbox.com/s/fpo9hkh100l84wt/output2.png?dl=0
It gets better…
Thanks
-
July 1, 2016 at 12:00 am #86190Ari SingerMember
The reason the script failed is because you probably copied the code from your email, and when you do that some characters don’t come through as they should. Try copying the code from my post directly, and try again.
-
July 1, 2016 at 12:41 am #86191Valentin OreillerMember
You’re right, it does something now. But there is a problem, it works on simple entries but when there is a space or a commercial caracter or carater like é (it is in french) it does not work. Furthemore, sometimes there is a number in the entry. I don’t know how to modify the expression and I can maybe introduce some special caracter before the page number to make the task easier.
Here an example of input and output :
input https://www.dropbox.com/s/6sb3wsh6lopda1x/example2.png?dl=0
output https://www.dropbox.com/s/vf4fj5ujp95uw23/output3.png?dl=0Thanks a lot!
-
July 1, 2016 at 11:24 am #86196Ari SingerMember
To be able to do it correctly I need to have an actual file to test on. Please copy the TOC to a new document and upload it here.
-
July 3, 2016 at 11:01 pm #86233Valentin OreillerMember
Hi,
Here : https://www.dropbox.com/s/d3bpbh26w1bnxjo/index.indd?dl=0Thank you!
-
July 4, 2016 at 12:56 am #86234Kai RübsamenMember
Hi all,
not a script, but I had the same question at the weekend, so I did it in this way:
Find what: (^.+)(\s?\t.+)\r\1\t
Change to: $1$2,The last character in ‘Change to’ is a space!
The GREP find always two lines. So ‘Change all’ needs to be executed multiple times.
Kai
-
July 4, 2016 at 4:29 pm #86257Ari SingerMember
Kai, your GREP string only seems to work in sets of two and not when there are multiple instances.
Valentin, here’s the updated script that should work as expected. But be aware that it will not work when there’s a regular space between the entry and the number, only a tab is allowed. So make sure that all the entries have proper tabs before the number.
Please let me know if this does work.
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Fix Duplicate TOC Entries"); function main() { var myDoc = app.activeDocument; cleanPrefs(); app.findGrepPreferences.findWhat = "(.+?)\\s\\d+\\r(\\1\\s\\d+\\r)+"; var foundText = myDoc.findGrep(); for (var i = foundText.length - 1; i >= 0; i--) { var curEntry = foundText[i]; app.findGrepPreferences.findWhat = "\\r(?=.)"; app.changeGrepPreferences.changeTo = ",\\s"; curEntry.changeGrep(); app.findGrepPreferences.findWhat = "(?<=, )(.+?)\\t(?=\\d+)"; app.changeGrepPreferences.changeTo = ""; curEntry.changeGrep(); } cleanPrefs(); } function cleanPrefs() { app.findGrepPreferences = app.changeGrepPreferences = null; }
-
July 5, 2016 at 12:34 am #86259Kai RübsamenMember
Hi Ari,
this is true. That’s why I said, you must execute it multiple times.
It does not take longer than the script to install ;-)Kai
-
July 5, 2016 at 6:50 am #86264Ari SingerMember
Sorry, Kai. Did not notice that line. It’s faster than a script but has its drawbacks as well. I tried it on the TOC that he provided and the results weren’t perfect.
-
-
July 5, 2016 at 7:02 am #86268Kai RübsamenMember
Hm, tried it also on the testfile and everything was found?!
-
July 5, 2016 at 7:10 am #86271Ari SingerMember
Take the first entry (“Bacs à plantes en béton”)for an example. After I ran the GREP the maximum amount of times, it still is divided in two entries. The culprit seems to be a space that was added in the process at the beginning of the first entry. But this occurs throughout the document with multiple entries.
-
July 5, 2016 at 8:25 am #86273Kai RübsamenMember
Do we have the same testfile? There is no space at the beginning of the first entry! To me it is logical, that the lines must be identical, if I want to find doubles ;-)
ah: Ari, if you get a space at the beginning, you don’t use my exact GREP!
-
July 5, 2016 at 9:42 am #86275Ari SingerMember
Yep! You’re right!
What happened was that when I copied your “Change To” string, along came a preceding space! (I should’ve been more careful, because this happens so often!). It does work now as expected. Thanks!
-
-
AuthorPosts
- You must be logged in to reply to this topic.