Skip to end of banner
Go to start of banner

How to remove pages which do not have specific labels using Confluence CLI

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 34 Next »

This article explains how to remove pages which do not have specific labels using Confluence Command Line Interface (CLI).

Instructions

Use runFromPageList to run actions for each page from a list of pages and use removePage to remove pages that do not have specific labels based on CQL.

For this example, consider a sample space with pages and labels added to them; where pages, page5 and page6, have labels, label2 and label3, respectively. Here, the pages that do not have the label label1; thus, the page5 and page6 pages are removed from the space.

  1. Ensure that the CLI client file is updated with the required information. 

  2. Run the following CLI action to remove the pages that do not have the specified label (in this example, label1):

    --action runFromPageList --cql "space = "JSON" and label not in ("label1")" --common "-a removePage --id @pageId@"
    

    In this example, the output of the CLI action is as follows:

    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 

    For this example, page5 and page6 pages are now deleted from the given space as shown:

The parameters used with the above action are:

  • --cql value refers to CQL content search.
  • --id value refers to numeric ID of an item like a page.

It is recommended to test the command in a non-production environment or run the action with the --simulate parameter to verify the behaviour before deploying.

  • No labels