Skip to main content
Level 4
Aug 27, 2019 5:49 PM UTC
Solved

Delete multiple pages in AEM 6.3 following a naming pattern

In AEM content hierarchy, I have a folder in which I have 4000 pages. And out of these pages, 3700 pages are following the naming convention of xyz-1, xyz-2, xyz-3..uptill xyz-3700 like this. I have a requirement to delete these pages starting with "xyz" but not the other 300 pages which have different names. I have tried below command with *, but this doesn’t work. Can anybody help me here to get this resolved?

curl  -F":operation=delete" -F":applyTo=/content/foo/bar/xyz*" http://localhost:4502 -u admin:admin

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Himanshu_Singhal
Himanshu_SinghalAccepted solution
New Participant
Aug 29, 2019 12:17 PM UTC

As already recommended, both the bash script and workflow option are feasible and can get the work. However, I'd recommend to go with bash script cos' that would be hassle free with no deployment required and have more control over what you want do. Obviously, you can do with workflow as well but since it's not the usual thing and mostly needs to be done only once, so considering all those factors, bash script would be nice option.

3 replies

Himanshu_Singhal
Himanshu_SinghalAccepted solution
New Participant
Aug 29, 2019 12:17 PM UTC

As already recommended, both the bash script and workflow option are feasible and can get the work. However, I'd recommend to go with bash script cos' that would be hassle free with no deployment required and have more control over what you want do. Obviously, you can do with workflow as well but since it's not the usual thing and mostly needs to be done only once, so considering all those factors, bash script would be nice option.

Translate
Aug 28, 2019 1:44 AM UTC

I would look at writing a workflow and a custom step. Then query pages under an AEM path. Delete those that meet the name pattern. 

Translate
Employee
Aug 28, 2019 1:37 AM UTC

As far as I can tell, the applyTo [1] will not work in this scenario (unless you want to list all the pages). I would suggest write a bash script that will loop through to delete these pages. [1] https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html

Translate