Copy Pages
Use Copy Pages to copy a page tree or pages from one location to another. To run the built-in script, you must have permission to view all the pages you are copying and permission to edit the target root page.
Run the script
Follow these steps to run the built-in script:
- Navigate to General Configuration > ScriptRunner > Built-In Scripts.
- Select Copy Pages.
Enter a space in Source Space to select the space the page tree is copied from.
Select the checkbox next to the page tree or pages you want to work with for Source Pages.
Enter a space in Target Space to select the page the information is copied to.
Select a checkbox next to the page that you want the information to be copied to in Target Page.
Enter the text you want at the beginning of the title in Title Prefix.
Enter the text you want at the end of the title in Title Suffix.
Use Title Replace to find and replace words in a title when copying.
To copy a page within the same space, manipulate the titles with a groovy closure because titles must be unique.
- Use the checkboxes for Inline Comments and Page Comments to choose to copy that content with the pages.
- Use the Notifications checkbox to send notifications for the update.
Use Code Transform to transform parts of the Confluence page with custom code.
Click Show Snippets for examples of custom code that you could use in this field.Select Run.
You can select Preview instead of Run to view changes before implementing them.
Once you select Run, the Results of the script appear.
Example
New version of documentation
When a new version of a product is released, product documentation is released with it. You can copy the entire documentation page tree using Copy Pages.
In this example, we will copy the pages of the Your Documentation Version 1 to Your Documentation Version 2, using Title Replace to rename pages with the version number.
Follow these steps to run the script:
- Navigate to General Configuration > ScriptRunner > Built-In Scripts.
- Select Copy Pages.
- Enter Your Documentation for Source Space.
- Select Version 1 in the Source Pages page tree.
- Enter Your Documentation Version 2 in Target Space.
- For Title Replace, enter Version 1 in the first field and Version 2 in the second field.
- Select Run.
Result
When you select Run, the pages are copied into Your Documentation Version 2.