This article explains how to remove pages that do not have specific labels using Confluence CLI.
Instructions
Use runFromPageList action to run actions for each page from a page list and removePage to remove pages that do not have specific labels based on CQL.
Ensure that the CLI client file is updated with the required information.
Here is a screenshot of a sample space with pages and labels added to them. Page5 and page6 have label2 and label3 respectively.Run the CLI action which will remove the pages that do not have a specific label. In this example it is label1.
Code Block theme Midnight --action runFromPageList --cql "space = "JSON" and label not in (\"label1\")" --common "-a removePage --id @pageId@"
The output of the CLI action:
Code Block theme Midnight Run: -a removePage --id 30310402 Removed page 'page5' in space JSON. Run: -a removePage --id 30310404 Removed page 'page6' in space JSON. Run completed successfully. 2 actions were successful
...