Teetan, first of all, after Jareks code, I correct my version a bit. Nevertheless my version is a bit longer than Jareks, because I check some things more, have a alert at the end and I’m not able to write such short scripts as Jarek (as a advanced beginner I have always problems with while loops …).
The trick ist the line nr. 16 SEARCH_Pattern. Here you can enter the right expression. E.g. if you want to find 2013 - 2016 change [4-6] to [3-6]. However: The script assumes, that you want to grow up numbers +1. So if you want to change other things on the masterpages, all those scripts from today won’t work and must be modified > new goals >> new scripts ;-)
if ( app.documents.length > 0 ) { if ( app.scriptPreferences.version >= 6 ) { app.doScript( main, ScriptLanguage.JAVASCRIPT , [], UndoModes.ENTIRE_SCRIPT, "Search in Masterpages" ); } else { main(); } } else { alert ( "No documents open!" ); } function main() { // Your settings // --- var SEARCH_PATTERN = '\\b201[4-6]\\b'; app.findGrepPreferences = app.changeGrepPreferences = null; app.findChangeGrepOptions.includeMasterPages = true; app.findGrepPreferences.findWhat = SEARCH_PATTERN; var target = app.documents.everyItem().masterSpreads.everyItem().textFrames.everyItem(); var allFounds = target.findGrep(); var counter = 0; for ( var n = 0; n < allFounds.length; n ++ ) { var framesFound = allFounds[n]; if ( framesFound.length > 0 ) { for ( var j = framesFound.length-1; j >= 0 ; j-- ) { var curFound = framesFound[j]; curFound.contents = String( Number( curFound.contents) + 1 ); } counter += framesFound.length; } // if } // for app.findGrepPreferences = app.changeGrepPreferences = null; alert( counter + " expressions have been changed." ); } // main
but not today. Sunny wheather. Let’s go outside .