How can I delete all the labels in a Confluence space using the Confluence CLI?
Asked by Iliya Bolotyansky:

Hi,  

How can I delete all the labels in a Confluence space, using the Confluence CLI?  
The CLI code I'm interested in should fetch all the labels used in a space, and delete them, without knowing the label names in advance (for example, there are over 150 labels per space).

Thanks for any further info,  
Iliya


Answers:
author: ryder
body: I know, the answer is really late. But I searched also for this question and found this post.

I also found the answer. The combination might look like this:

```
 --action runFromPageList --space mySpace --id my_ID_from_top_page --continue --descendents --common "--action getLabelList --id @pageId@"
```

This command print out all labels for all pages below page with page ID my_ID_from_top_page.

Depending on the number of pages, it might be convenient to wrap a little bash code around to get a filtered answer.

Hope this help somebody in the future.

Kind regards,

ryder


author: Shannon S
body: Hi Iliya,

You can [remove a label from a set of pages](https://bobswift.atlassian.net/wiki/spaces/CSOAP/pages/33652917/How+to+remove+a+label+from+a+set+of+pages) using CLI, and there also appears to be an option to [runFromPageList](https://bobswift.atlassian.net/wiki/spaces/CSOAP/pages/91881522/Documentation#Documentation-runFromPageList) to do this in bulk.

Have a look at that page and do let us know if you have any questions.

Kind Regards,  
Shannon

comments: author: Iliya Bolotyansky
body: Hi Shannon,

Would it be possible to see a Confluence CLI example that does that? I'm new to Confluence CLI, and have been unable to construct the right command statement to remove all the labels from the space. Also, it's not about removing a specific label from a set of pages. In my case, I don't know the label names in advance, or how many of them exist. I need to aggregate them and then remove them from the space. Is there a way to do that?  

Thanks,  
Iliya


author: Shannon S
body: Hi Iliya,

[@Bob Swift (personal)](/t5/user/viewprofilepage/user-id/781458) mentioned the following example in a [previous question](https://community.atlassian.com/t5/Confluence-questions/Using-CLI-to-remove-one-label-from-all-the-pages-in-a-space/qaq-p/186337):

```
--action runFromPageList --space SPAC --common "--action removeLabels --labels purple --id @pageId@"
```

You can list multiple labels in quotes like this:  
--labels "label1, label2, label3"  
He also has a method to get a list of labels using [getLabelList](https://bobswift.atlassian.net/wiki/spaces/CSOAP/pages/91881522/Documentation#Documentation-getLabelList). You could use this to obtain the list of labels you need to remove.  
Kind Regards,  
Shannon


author: Iliya Bolotyansky
body: Hi Shannon,

I know this example. My question is, how do I combine "getLabelList" (to aggregate all the labels, since I don't know them in advance, and there are over 150 of them) with "runFromPageList" over a specific Confluence space in a single CLI command?

Thanks,  
Iliya


author: Shannon S
body: Iliya,

Unfortunately I'm not familiar enough with the CLI which is a third-party add-on, but hopefully the team behind it will see your question here and be able to assist you with that. I have properly tagged it so they can see it.

Otherwise you can consider [contacting them directly](https://marketplace.atlassian.com/plugins/org.swift.confluence.cli/server/support) and they may be able to assist you there.

Kind Regards,  
Shannon


Tags: addon-org.swift.confluence.cli

atlassian-marketplace