Example scripts
To homepage
New
Confluence

Find and Replace Text Across Space
App in script

ScriptRunner For Confluence
by Adaptavist
Compatibility

Confluence
Language |
groovy
def spaceKey = 'ans'
def oldText = 'test'
def newText = 'page'
def pages = Spaces.getByKey(spaceKey).getAllPages(){
setBodyFormat("storage")
}
pages.findAll { page ->
def storage = page.body.storage.value
def newContent = storage.replace(oldText, newText) // case sensitive replace
if (newContent == storage) {
return false
}
logger.info("Updating page '${page.title}' with new body")
page.update(){
title = page.title
status = "current"
body = newContent
}
logger.info("Page '${page.title}' has been updated.")
return true
}.collect { it.id }Having an issue with this script?
Report it here