Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Does "Scriptrunner for Confluence" allow moving multiple pages using a label?

I've seen plenty of questions on this and almost every answer is "click and drag" which is not practical for hundreds of pages of varying hierarchy in a single Confluence space. There is one single unanswered question on this very topic that I could find: (https://community.atlassian.com/t5/Confluence-questions/How-to-move-multiple-pages-with-a-certain-label/qaq-p/995497)

The question is simple: Does Confluence (or Scriptrunner for Confluence) provide a method to move pages in bulk (with a certain label, e.g. "Archive") to another top-level page in the same Space? 

None of the built-in scripts in "Scriptrunner for Confluence" provide even a clue on moving multiple pages. It's all adding labels, notifications, etc. Ok, that's great, but is there seriously no way to move all these unless by "click and drag"??

I have the first portion of my script running as a Job below, I just want to move these newly labeled pages to a new top-level page. Can anyone here please provide something beyond the template "click and drag" response, or is this just where Confluence is still at since 2004

 

import com.atlassian.confluence.labels.Label
import com.atlassian.confluence.labels.LabelManager
import com.atlassian.confluence.labels.Namespace
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.scheduler.JobRunnerResponse

def labelManager = ComponentLocator.getComponent(LabelManager)
hits.each { page ->

def labelName = "Archive"

def label = labelManager.getLabel(labelName)
if (!label) {
label = labelManager.createLabel(new Label(labelName, Namespace.GLOBAL))
}

if (!page.labels*.name.contains(labelName)) {
log.info("Add label to page: ${page.title}")
labelManager.addLabel(page, label)
}
}

2 answers

1 accepted

1 vote
Answer accepted
Steven Behnke Community Leader Sep 23, 2019

Import the class PageManager and then use one of the various move page methods.

https://docs.atlassian.com/atlassian-confluence/6.6.0/com/atlassian/confluence/pages/PageManager.html

Hey Jayron32X,

Were you able to get this running?

Can you provide your script here? :D

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

302 views 23 8
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you