Ok, I think I've worked it out.
main();
function main(){
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
app.findGrepPreferences.findWhat="~N";
var FindGrep=app.activeDocument.findGrep();
for(i=0; i<FindGrep.length; i++)
{
var item = FindGrep[i];
var page = item.parentTextFrames[0].parentPage;
item.contents = page.name;
}
alert("done");
}
Struggled to find any valuable documentation from Adobe.
This really helped: http://jongware.mit.edu/idcs5/
As well as this SO question: Get current page number in InDesign CS5 from Javascript
Edit: If your page numbering is in a master, you will need to "override all page master items" (check the pages palette)
Edit 2: This worked on inDesign 5.5 (not sure about 6)
Edit 3: Works also on InDesign CC