Hi @Anthony D. Paular, in addition to the AppleScript that Eugene gave us, here is an ExtendScript version. If you need to re-purpose it, you can just change this function:
var changeNumber = function (n) { return n < 336 ? n : n + 2 };
Can you understand it? If n < 336 you get n but otherwise you get n + 2.
- Mark
/**
* @file Change Numbers.js
*
* Changes numbers in selected text.
*
* @author m1b
* @version 2025-05-15
* @discussion https://community.adobe.com/t5/indesign-discussions/need-to-change-numbers-in-an-index-2-after-336/m-p/15321400#M624683
*/
function main() {
// this is the number changing logic, you can edit this:
var changeNumber = function (n) { return n < 336 ? n : n + 2 };
var doc = app.activeDocument,
text = doc.selection[0];
if (
undefined == text
|| 'function' !== typeof text.findGrep
)
return alert('Please select some text and try again.');
// clear the find/change grep preferences
app.findGrepPreferences = NothingEnum.nothing;
// set the grep to search for page numbers
app.findGrepPreferences.findWhat = '\\d+';
// perform the find
var found = text.findGrep();
for (var i = found.length - 1; i >= 0; i--) {
found[i].contents = String(changeNumber(Number(found[i].contents)));
}
};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Change Numbers');
Edit 2025-05-15: better explanation.