Copy link to clipboard
Copied
Basically I need to increase every digit in bold underline(bold underline for emphasis, not in original document) in the text below (just an example of much larger document) by 1 and I'm hoping there's some GREP or plug-in way to do it. If anyone has any ideas outside of indesign, I'm open to them too (word or excel etc!). Thanks in advance!
<navMap>
<navPoint id="d3-d333afd81907b-d1e86" playOrder="1">
<navLabel>
<text>Title Page</text>
</navLabel>
<content src="OEBPS/9780008216528_epub_tp.xhtml"/>
</navPoint>
<navPoint id="d3-d333afd81907b-d1e107" playOrder="2">
<navLabel>
<text>Copyright</text>
</navLabel>
<content src="OEBPS/9780008216528_epub_cop.xhtml"/>
</navPoint>
<navPoint id="itocmarker" playOrder="3">
<navLabel>
<text>Table of Contents</text>
</navLabel>
<content src="OEBPS/9780008216528_epub_itoc.xhtml"/>
</navPoint>
<navPoint id="d4-dd0ff6d8ed905-d1e101" playOrder="4">
<navLabel>
<text>Prologue</text>
</navLabel>
<content src="OEBPS/9780008216528_epub_chap001.xhtml"/>
</navPoint>
I'm such a ditz at times
You want to increase by 1 like playorder 1 becomes playorder 2 -------- sigh I thought just meant in size or something.
This has come up before and I have a similar script so have something here that works.
(function () {
if (app.documents.length === 0) {
alert("No document open.");
return;
}
var doc = app.activeDocument;
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
// Match onl...
Copy link to clipboard
Copied
Find
\="\K\d+(?=")
Copy link to clipboard
Copied
I'm such a ditz at times
You want to increase by 1 like playorder 1 becomes playorder 2 -------- sigh I thought just meant in size or something.
This has come up before and I have a similar script so have something here that works.
(function () {
if (app.documents.length === 0) {
alert("No document open.");
return;
}
var doc = app.activeDocument;
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
// Match only numbers within playOrder="###"
app.findGrepPreferences.findWhat = '(?<=playOrder=")\\d+(?=")';
var results = doc.findGrep();
if (results.length === 0) {
alert("No playOrder numbers found.");
return;
}
for (var i = 0; i < results.length; i++) {
var num = parseInt(results[i].contents, 10);
if (!isNaN(num)) {
results[i].contents = (num + 1).toString();
}
}
alert("All playOrder values have been increased by 1.");
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
})();
Copy link to clipboard
Copied
You are my favourite human on the planet, thank you so much!!!
Copy link to clipboard
Copied
You beat me to it @Eugene Tyson I used exactly the same grep—great minds think alike! 🙂 Here's a demo document to help.
- Mark
Copy link to clipboard
Copied
Haha @Eugene Tyson speaking of great minds again.. I thought exactly what you did. Now I read it properly. Sorry OP!
Copy link to clipboard
Copied
Yeh the increasing the number thing has come up before on the forums for scripting, it's in my library already. So was an easy one 😛
Copy link to clipboard
Copied
Thanks for answering - you've helped me out before here, thanks!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now