Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi,
Hi @Jagadeesh Welcome to the Atlassian Community!
This blog on scriptrunner site already have a script that you can download and modify as per your requirement. The example script works on a single space, but you can modify the code to loop through all your confluence spaces and its pages and perform search/replace as per your use case.
Hi Kishan,
Thank you very much for your quick reply. Yes, I am using the sample script shared by the Script runner trial version tool, but it is throwing errors and I need someone who has already used this script to help me in debugging or modifying the current script.
The sample script shows how to modify within a table in confluence page, I want to modify text within a page in confluence. I am not sure what code elements to use. if you have an idea how to modify the script, please do message me at this mail id
jmadineni@billtrust.com. I will be very thankful for helping me out.
Regards,
M Jags
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jagadeesh,
I will also suggest posting this question to Atlassian Developer Community so that you will get better solutions from the developers working on such scripting activities. I will also post here in case I able to get this to work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kishan,
Thanks for the suggestion. Sure, I will post in the developer community too. I have another 10 days before the trial version expires. In the meanwhile, if you know any groovy script developers please suggest their mail ids. I will try connecting with them.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey, I just publicized a Node.Js script I created and have been using for bulk replacing text within a Confluence Cloud space.
There are two .js scripts included, one for swapping page content (index.js), and one for updating page titles (updatePageTitles.js).
Hopefully this helps someone!
https://github.com/krgainer/confluence-bulk-change
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Welcome to the Atlassian Community and thank you for sharing the script @Kieran Gainer !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jagadeesh,
Here's what your script might look like if you wanted to find and replace text anywhere on particular Confluence pages:
import com.atlassian.confluence.pages.PageManager
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.sal.api.component.ComponentLocator
import org.jsoup.Jsoup
def pageManager = ComponentLocator.getComponent(PageManager)
def spaceManager = ComponentLocator.getComponent(SpaceManager)
def targetSpace = spaceManager.getSpace("SAL")
pageManager.getPages(targetSpace, true).each { page ->
log.debug "Inspecting page ${page.title}"
def body = page.bodyContent.body
body = body.replace('Human Resources', 'HR')
pageManager.saveNewVersion(page) { pageObject ->
pageObject.setBodyAsString(body)
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi cami!
I'm sure this is possible with ScriptRunner for Confluence Cloud, but your script will look pretty different because you'll have to use the Confluence Cloud Rest API.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Tiffany. The Confluence Cloud REST API documentation states that connect apps cannot access the rest resource necessary to perform that action. Isn't ScriptRunner a connect app?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.