Bulk delete + Buly Copy

Danny Winbourne asked on February 21, 2022 18:41

I have a site with 100+ parent pages, which all have a similar child page structure. Is there a way to delete all child pages of a certain name, using a SQL script? I know I can do this with custom code, but there might not be the budget or time for this.

i.e. /parent-page-1/contact /parent-page-1/about /parent-page-2/contact /parent-page-2/about /parent-page-3/contact /parent-page-3/about /parent-page-x/contact /parent-page-x/about

Secondly, I'd like to copy the same folder (and child items) to be a child page for all the parent pages.

Again, I am hoping to avoid custom code, and hoping there is a quicker way using SQL, but appreciate this might not be feasible.

Recent Answers


Danny Winbourne answered on February 21, 2022 18:57

Having a quick play with the API, I might be able to do this quicker than I thought. But still might be useful if anyone does have a good SQL script to delete a page.

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on February 22, 2022 05:48

Hi Danny,

The delete one is pretty easy, you don't need a script for it. Just select the top-level node page in the tree, switch to Listing mode, then in the Name contains search type "about" for example and tick "Show all levels" checkbox, alternatively in the top right corner there is also a page type filter. Once your search and filter capture all desired pages you can mass-delete those.

The copy task you mentioned is a little bit trickier though. I'd consider these options:

  • Prepare an excel spreadsheet with these pages then import via Import Toolkit, it allows multiple destinations
  • Run a small console app locally to copy pages via API, then sync those pages to next environments via Staging

Please keep in mind that manipulating pages and tree via SQL isn't a good practice because there are so many tables involved and it's easy to mess up with the database.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.