Bulk move pages based on last modified

Kathryn Smith May 31, 2020

Hello.

We recently installed power scripts add on in our confluence environment in preparation for a cleanup.

One item on our list is to move all pages that were last modified on or before 2015 are to be moved to a temporary space for about 6 months which afterwards would be deleted if none of the pages were claimed or screamed for.

I'm wondering if we can use power scripts for this and if possible what would the script look like (not being a developed or coder I'm a bit of a fish out of water here).

Thanks in advance.

1 answer

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 22, 2020

Hello @Kathryn Smith ,

Create a space for keeping all archived pages. Get the id of the home page of this space.

Then you could create a script like this:

number archiveSpacePageId = 111011;

for (string s in getAllSpaces()) {
for (number p in selectPages("space = " + s)) {
if (p.updated < "2015-01-01") {
movePage(p, archiveSpacePageId);;
}
}
}

 archiveSpacePageId is the id of the home page of the space, which will keep all archived pages.

Kathryn Smith July 22, 2020

Wow thanks @Alexey Matveev .

I do apologise. Is there a way this script to be altered to target a specific space to move pages from that were last modified 2015-01-01 rather than all spaces. EG: i have a space called 7. TRUCKS - can I test this script from this space to the archive space?

Annotation 2020-07-23 091940.jpg

I unfortunately I do not have a test confluence environment to test this out in and if i moved all the pages that this script would target then i would be impacting a live environment and i might lose my job!

Thanks you so much aswell - super appreciative.

Kat

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 23, 2020

@Kathryn Smith ,

You can write a script like this:

number archiveSpacePageId = 111011;
string sourceSpace = "7. TRUCKS";

for (number p in selectPages("space = " + sourceSpace)) {
if (p.updated < "2015-01-01") {
movePage(p, archiveSpacePageId);;
}
}
 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events