Mark, on second thought, I think they want the numbering to be automated for the day. Not necessarily a continuation.
Ah I see. You're probably right. This is how I would approach that problem...
1. Open attached indesign sample file. I've set up the Day numbers in a character style "Day Placeholder".
2. run the below script. It will replace the contents of any text set in that style with an incrementing number, starting at 1. Important note: you can use master pages to place the day number text frames, but they must each be overridden before the script will see them.
- Mark
function main() {
enumerateTextsInCharacterStyle(app.activeDocument, 'Day Placeholder');
/**
* Replaces any text in specified character style
* with an index, starting at 1.
* @7111211 m1b
* @version 2022-08-27
* @9397041 {Document} doc - an Indesign Document.
* @9397041 {String} styleName - the characterStyle name.
*/
function enumerateTextsInCharacterStyle(doc, styleName) {
var changeStyle = doc.characterStyles.itemByName(styleName);
if (!changeStyle.isValid) {
alert('There is no character style named "' + styleName + '".');
return;
}
app.findGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.appliedCharacterStyle = changeStyle;
var found = doc.stories.everyItem().paragraphs.everyItem().findGrep();
for (var i = 0, counter = 1; i < found.length; i++) {
for (var j = 0; j < found.length; j++) {
if (
found[i][j] != undefined
&& found[i][j].hasOwnProperty('texts')
)
found[i][j].contents = String(counter++);
}
}
}
} // end main
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Update Day Numbers');