Skip to main content
Example scripts
arrow icon
To homepage
Confluence
Data centre icon
Data Center

Automate the Removal of Old or Inactive Content

Features
Jobs
Created 1 year ago, Updated 1 month(s) ago
App in script
ScriptRunner For Confluence
ScriptRunner For Confluence
by Adaptavist
Compatibility
compatibility bullet
Confluence (7.15 - 8.6)
compatibility bullet
ScriptRunner For Confluence (7.10.0)
Language |
groovy
import com.atlassian.confluence.core.DefaultDeleteContext
import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager
import com.atlassian.sal.api.component.ComponentLocator

def pageManager = ComponentLocator.getComponent(PageManager)
def pages = hits as List<Page>

log.info("Total number of pages to be trashed: ${pages?.size()}")

pages?.each { Page page ->
    log.info("Page: ${page.title} in Space: ${page.spaceKey} was moved to the trash")
    pageManager.trashPage(page, DefaultDeleteContext.DEFAULT)
}

"CQL search returned ${pages?.size()} inactive item(s). Each item was removed"
Having an issue with this script?
Report it here