Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Is it possible to do an operation on a found digit in indesign?

Community Beginner ,
Oct 17, 2025 Oct 17, 2025

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>

TOPICS
Scripting
334
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 17, 2025 Oct 17, 2025

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
...
Translate
Community Expert ,
Oct 17, 2025 Oct 17, 2025

Find

\="\K\d+(?=")
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 17, 2025 Oct 17, 2025

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;
})();

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 17, 2025 Oct 17, 2025

You are my favourite human on the planet, thank you so much!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 17, 2025 Oct 17, 2025

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 17, 2025 Oct 17, 2025

Haha @Eugene Tyson speaking of great minds again.. I thought exactly what you did. Now I read it properly. Sorry OP!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 17, 2025 Oct 17, 2025

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 😛 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 17, 2025 Oct 17, 2025
LATEST

Thanks for answering - you've helped me out before here, thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines