labels in confluence
Asked by Nico de Jong:

heaving read the confluence manual I think that it isn't possible to change al pages with the label "X" to a page with the label "Y" in bulk

*You can't remove, consolidate or manage labels directly. A labels are created by adding it to a page*

Is my assumption correct or do I miss something? Is there perhaps feature request for this?

Thankx for reading/answering my question!


Answers:
author: Mirek
body: This is not available OOTB. Some day ago I was using this macro

<https://bitbucket.org/stephendeutsch/confluence-user-macros/src/dc9180ae95e0292cba2b457c0215f071d39330c9/label%20management%20tool/?at=master>

Not sure which version of Confluence you are having, but you can give it a try. If not this then maybe a plugin might be helpful. For example:

<https://marketplace.atlassian.com/plugins/com.kostebekteknoloji.plugins.confluence.confluence-label-manager/server/overview>


author: Christoffer Bromberg _K15t_
body: You could search the pages via CQL and then set the new label via REST

<https://developer.atlassian.com/cloud/confluence/rest/#api-search-get>, e.g.

```
GET {{baseUrl}}/rest/api/content/search?cql=type = page and label in ('X')&expand=metadata.labels
```

and then set the new labels via <https://developer.atlassian.com/cloud/confluence/rest/#api-content-id-put>, e.g.

```
?PUT??{{baseUrl}}/rest/api/content/{{contentId}} with body 
```

```
{"type":"page",
"title": "Test page",
"metadata": {
"labels" : [
{ "prefix": "global",
"name": "Y" }
]
},
"version": { "number" : 2 }
}
}
```

That could be scripted pretty easy using client-side code or scripting on the server, e.g. curl. You could even build a JS only plugin for that :)

This would work for server and cloud

comments: author: Chela Wallace
body: Would this work for doing a bulk change of labels across a space, specifically to change the underscore to a hyphen?

this_label \>\> this-label


author: Christoffer Bromberg _K15t_
body: Sure. You retrieve the old labels, exchange the label to exchange, and PUT them back as described above. You just need someone with some scripting experience - if you don't have access to such people in your org, ask your Atlassian Solution Partner, use one of the Apps mentioned below (or take the chance to learn it yourself :nerd:)


author: Christo Mastoroudes _Adaptavist_
body: Hi Nico,

If you have the ScriptRunner for Confluence app you can do some bulk operations on labels, or write your own script to help with managing labels.

Alternatively as Mirek mentioned, there are other apps available on the marketplace that could help.


author: Stephen Deutsch
body: [@Mirek](/t5/user/viewprofilepage/user-id/781521) Thanks for the mention on the label management tool. It will need to be installed as a user macro and then embedded in a page before you can use it.

In case you are using Confluence Cloud, you could also use the [Bulk Action Tools](https://marketplace.atlassian.com/plugins/bulk-action-tools/cloud/overview) Marketplace app to rename labels.


author: Michele Lim [Cprime]
body: Hey [@Nico de Jong](/t5/user/viewprofilepage/user-id/1167617),

We have recently made a free plug in [Power Scripts for Confluence](https://marketplace.atlassian.com/apps/1219507/power-scripts-for-confluence?hosting=server&tab=overview) which you can download from the Marketplace to help automate Confluence administration, one of the features is bulk label admin. Here's the script:

<https://confluence.cprime.io/display/CTR/Replace+a+label+with+a+different+one>

Hope this helps!

Michele


Tags: confluence-cloud