Copy link to clipboard
Copied
I have a three volume book, whose pages are in the form I:1, I:2...II:1, II:2...III:1, III:2... My problem is the index to the three volumes, which looks like this: topic I:23, I: 34, I: 245, I:450, II: 345, II: 451, III: 24, III: 45 and so forth. Can I somehow remove these repeated volume numbers so that I get a normal (and much less cluttered) multi-volume index, namely "I: 23, 34, 245, 450; II: 345, 451; III: 24, 45"?
Dropbox - Multi-volume Index.jsx Script updated, now it works, at least with the file you sent me, but this index list is long - there are over 5 000 instances that need to be checked/sorted and formatted the way you like, so it takes time... in my computer with core i5 processor (4 cores, 3.5 GHz), 20 Gb ram, and Windows 10 it took me 2.5 minutes to complete (you need to wait till you get message "Done!" or some error).
So I suggest splitting this index into the smaller pieces - run script on th
...Copy link to clipboard
Copied
I believe this can be done with InDesign script (.jsx file)
For example, this GREP will search for Roman digits:
(\\<(M{0,3}(D?C{0,3}|C[DM])(L?X{0,3}|X[LC])(V?I{0,3}))\\>)
and the script should check Roman and Arab digit sequences and remove the second and following Roman digits in the row...
this GREP will find entire sequence - "I:23, I: 34, I: 245, I:450, II: 345, II: 451, III: 24, III: 45"
(((\\<(M{0,3}(D?C{0,3}|C[DM])(L?X{0,3}|X[LC])(V?I{0,3}))\\>):\\s?\\d+(,\\s)?))+
from what was found - search
(((\\<(M{0,3}(D?C{0,3}|C[DM])(L?X{0,3}|X[LC])(V?I{0,3}))\\>):\\s?
and remove 2nd and following occurrences
Copy link to clipboard
Copied
When you say "remove 2nd and following occurrences," do you mean that I have to remove these manually? There are thousands of them and I am looking for a way to remove them automatically. For example, I can remove the "I:" after every first occurrence by doing a find on ", I:" and changing all to ", " so that, for example, American Revolution I:120, I:124, I:132, II:39, II:59, II:73, II:346, III:52 becomes American Revolution I:120, 124, 132, II:39, II:59, II:73, II:346, III:52 but I can't figure out how to get rid of the second and further occurrences of "II:" and "III:"
If the first volume entries were separated from the second volume entries by a semi-colon (or anything else) instead of a comma, I could change all ", II:" to ", " but with nothing but commas, doing this would remove the first occurrence of "II" and "III" in all my entries.as well.
Any thoughts?
Copy link to clipboard
Copied
just try this script and let me know if it works.
code if far from perfect, but it seems to be working...
Dropbox - Multi-volume Index.jsx
https://indesignsecrets.com/how-to-install-scripts-in-indesign.php
Copy link to clipboard
Copied
When I put the script in the scripts folder and double click on it, I get a dialog box that says "Select text to sort and try again!" If I then select the index (or any text from it), I get the same message.
Copy link to clipboard
Copied
strange, it works on my side...
I made some changes so it should now show more specific error message - redownload script from the same location, select text frame or text itself and try to run script one more time.
if it still does not work - you may ask in this scripting forum InDesign Scripting
Copy link to clipboard
Copied
I need a new link to Dropbox; the old one no longer works since the old script has been deleted.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
This time I get the message, "Java Script Error" #89867, "Error string: the default engine 'main' cannot be deleted," and a little later, "line 65."
Copy link to clipboard
Copied
sorry, I don't know why this is not working for you, try to ask at this forum InDesign Scripting
Copy link to clipboard
Copied
Thanks for your help. I put this question on the InDesign Scripting Scripting board last Tuesday but have not had any responses. Do you think I should keep waiting, or do you have any other suggestions on where I might look for help?
Copy link to clipboard
Copied
you can try to post your question/request here https://indesignsecrets.com/forum/indesign-add-ons-scripts-scripting-and-plug-ins
Copy link to clipboard
Copied
I dont know if this helps, i have not tested this script myself.
Try to replace
exit(e);
in the script Multi-volume Index.jsx (rows 33 and 65) with:
alert("Error: "+ e.message);
exit();
Copy link to clipboard
Copied
When I try the revised script I get JavaScript error #2 (problem in line 36) "Error String: whereToSearch is undefined"
Copy link to clipboard
Copied
Peter
Just a small clarification. My change only allows you to get a message that tells you something about what has gone wrong.
Take a look at this part in your script, that tries to define "whereToSearch":
switch(app.selection[0].constructor.name){
case "InsertionPoint":
case "TextFrame":
whereToSearch = app.selection[0].parentStory;
break;
case "Paragraph":
case "Text":
case "Line":
whereToSearch = app.selection[0];
default:
whereToSearch = app.activeDocument;
}
To mee it looks like you have to make a selection in your document before you run the script.
Copy link to clipboard
Copied
Yes, thanks. I did forget to select the text.
Now I get the message "Null is not an object"
Copy link to clipboard
Copied
I made some changes, now everything should be ok - have a try and let me know if it works
https://www.dropbox.com/s/zjeabd6x3xnjihm/Multi-volume%20Index.jsx?dl=1
right now - if nothing selected - changes will be applied to all text frames in the opened / active document, if only one text frame selected - changes will be applied only to selected text frame, and finally - if you select some text - changes will be applied only for this selection.
if you still have some problems - can you share the document you are working with? Or at least one page...
Copy link to clipboard
Copied
We must be getting closer. The latest version works perfectly on 5-10 lines of he index, but if I try to do more, it has no effect on any of it. If I then go back and do a few of the same lines, it works.
Thanks for working on this.
Copy link to clipboard
Copied
this is strange, maybe if there are too many instances - all you need is wait a bit longer?
check this update but I'm not sure if this will help Dropbox - Multi-volume Index.jsx
need to check with the real problematic file - in my test example if successfully process 24+ text frames with different sequences
Copy link to clipboard
Copied
This script also works fine with perhaps 10-15 lines but when I try to do more, or do a text frame, I get the message Error Number: 27 Error String: stack overrun
Is it possible for me to send you the original index?
Copy link to clipboard
Copied
yes, you should be able to send me a direct message here or you can send me email > oleh.melnyk at gmail.com if you are not able to share it publically (via dropbox or any other services) so other forum members could also help with the problem
Copy link to clipboard
Copied
Here is the index. I eliminated the extra vol. 1 volume numbers without needing a script. Now I am trying to remove the extra vol. 2 and 3 volume numbers. http://https://www.dropbox.com/s/f3fdv88xc9gmrgb/Index.indd?dl=0
Copy link to clipboard
Copied
Sorry; let me do that again.https://www.dropbox.com/s/f3fdv88xc9gmrgb/Index.indd?dl=0
Copy link to clipboard
Copied
Dropbox - Multi-volume Index.jsx Script updated, now it works, at least with the file you sent me, but this index list is long - there are over 5 000 instances that need to be checked/sorted and formatted the way you like, so it takes time... in my computer with core i5 processor (4 cores, 3.5 GHz), 20 Gb ram, and Windows 10 it took me 2.5 minutes to complete (you need to wait till you get message "Done!" or some error).
So I suggest splitting this index into the smaller pieces - run script on them and then when, and only when everything is ready - merge them down.
UPD: in some cases, it might look like the script has skipped some instances - most likely this means that problem is related to the source - it didn't match the pattern for some cases - you already edited something or made a typo, or changed something intentionally... The script should not try to read your mind and guess why some lines didn't match the pattern. So it's up to you to make sure everything is consistent and correct in the source. But anyway I believe that what my script does is much better than doing everything manually.
Copy link to clipboard
Copied
It worked! It took a few passes, but then picked up most of the repeated volume numbers.
Thank you so much for continuing to work on this script!
(Now that I know how to use scripts, maybe I'll use them more often in Indesign.
In any case, I am grateful for all your help,
Peter Ray