How to copy a page hierarchy to the same space

Description

Copying a page hierarchy to the same space needs to be done carefully as Confluence doesn't allow duplicate page names in a single space. This is solved by using the @title@ replacement variable so you can change the names of all the target names using a prefix or similar.

Example

confluence --action copyPage --space Examples --title "My example" --descendents --newTitle "PREFIX - @title@" 

Page 'My example' copied to 'PREFIX - My example' in examples.
Page 'My example 1.1' copied to 'PREFIX - My example 1.1' in examples with parent 'PREFIX - My example'.
Page 'My example 1.2' copied to 'PREFIX - My example 1.2' in examples with parent 'PREFIX - My example'.
Page 'My example' with 2 descendents copied to 'PREFIX - My example' in space examples.  Page has id: 341186939.