Copy link to clipboard
Copied
Hi Guys,
I am searching code to open page range in InDesign file. Is anybody can share the JS code to open page ranges in ID document CS5.5
See below the screenshot of the entries in the document. Some entries my have single digit after en dash.
I hope will get this soon with positive response.
Regards,
DanuP
Message was edited by: Danu Prasad
This forum is not meant as an access hub to ask people write you free custom scripts.
.. But -- fortunately for you, this particular question was interesting enough to spend 5 minutes on. It turned out to be as easy as I initially thought:
...app.findGrepPreferences = null;
app.findGrepPreferences.findWhat="\\d+[-~=]\\d+";
r = app.activeDocument.findGrep(true);
while (r.length)
{
t = r.pop();
s = t.contents.split(/\D/);
s[1] = s[0].substr(0,s[0].length-s[1].length)+s[1];
s[0] |= 0; s
Copy link to clipboard
Copied
This forum is not meant as an access hub to ask people write you free custom scripts.
.. But -- fortunately for you, this particular question was interesting enough to spend 5 minutes on. It turned out to be as easy as I initially thought:
app.findGrepPreferences = null;
app.findGrepPreferences.findWhat="\\d+[-~=]\\d+";
r = app.activeDocument.findGrep(true);
while (r.length)
{
t = r.pop();
s = t.contents.split(/\D/);
s[1] = s[0].substr(0,s[0].length-s[1].length)+s[1];
s[0] |= 0; s[1] |= 0;
u = s[0];
while (s[0]++<s[1])
u+=', '+s[0];
t.contents = u;
}
Copy link to clipboard
Copied
Hi Jongware,
I've not tested your code lines but I suppose you don't take into account the fact that it is an index. So the page numbers should normally contain links to those pages. In your script, it's not the case. Am I right?
Copy link to clipboard
Copied
That's not the OP's question. My script works on the set of numbers shown in the example (labouriously typed in, *sigh*), and it does not matter whether the ranges are page numbers or something else.
Copy link to clipboard
Copied
You're right! It is a way to see the issue!
However, I'm curious to see Peter Kahrel's view offering folios compacting in one of his scripts!
See: Update index | Peter Kahrel
… because ultimately, IMHO, the question could be: is it possible to "uncompact"?
friendly, Obi-wan
Copy link to clipboard
Copied
> IMHO, the question could be: is it possible to "uncompact"?
well, that's what Danu's question was, and that's exactly what Jongware's script does.
Peter
Copy link to clipboard
Copied
Hi Peter,
Sorry, it's not exactly the answer to my question. What I mean:
If I use your script to "compact" the folios in an index, is there a way to "undo" it and retrieve all index links?
That is: do the opposite of your script!
Copy link to clipboard
Copied
The opposite of my script is Jongware's script
On Thu, 20 Nov 2014 13:09:40 -0000, Obi-wan Kenobi
Copy link to clipboard
Copied
Ah, and no, those links won't work any longer. I was never bothered about
those links.
On Thu, 20 Nov 2014 13:09:40 -0000, Obi-wan Kenobi
Copy link to clipboard
Copied
Peter, Jongware and Danup,
If the index is approached from the right angle [this is, according to me, a pure question of timing in the management of the index generation process!], the compacting folios manipulation is "normally" the end of an index treatment.
So, in this case, it will suffice to regenerate the index! Without any loss.
[However, I still think that [Javascript] + UI would be THE solution to index global management when the entries are "marked" in ID!]
Copy link to clipboard
Copied
Hi Jongware,
First, I would like to appreciate you to spend some time and providing me the correct answer. Its really very encouraging to see top participants like you and Peter in my post.
Thanks again for your cooperation.
Regards,
DanuP
Copy link to clipboard
Copied
Hi Jong,
I have 2 questions to you, that would be appreciable.
1. Could you elaborate your code, I am new in scripting, please?
2. Same thing can you reverse to range number again, like 111, 112, 113, 114 to 111-4 or 118, 119, 120, 121 to 118-21?
Regards,
Sumit
Find more inspiration, events, and resources on the new Adobe Community
Explore Now