Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to Delete DAM asset which is having specific property in AEM using servelt or groovy script?

Avatar

Avatar
Level 1
chandrareddy
Level 1

Likes

0 likes

Total Posts

5 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
chandrareddy
Level 1

Likes

0 likes

Total Posts

5 posts

Correct Reply

0 solutions
View profile
chandrareddy
Level 1

11-02-2021

Hi Team,

 

Can someone suggest how to delete DAM documents which is having particular property either servlet or groovy script or any other methods?

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
MVP
raj_mandalapu
MVP

Likes

124 likes

Total Posts

203 posts

Correct Reply

72 solutions
Top badges earned
Validate 1
Contributor
Shape 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 1
MVP
raj_mandalapu
MVP

Likes

124 likes

Total Posts

203 posts

Correct Reply

72 solutions
Top badges earned
Validate 1
Contributor
Shape 1
Give Back 5
Give Back 3
View profile
raj_mandalapu
MVP

11-02-2021

I have taken groovy script code from the below article and modified according to your reuirement, but did not test this code, you need to test this in the local before running into production or QA.

https://hashimkhan.in/aem-adobecq5-code-templates/groovy-script/

 

def predicates = [path: "/content/dam/geometrixx", type: "dam:Asset", "orderby.index": "true", "orderby.sort": "desc"]
def query = createQuery(predicates)
query.hitsPerPage = 500
def result = query.result
println "${result.totalMatches} hits, execution time = ${result.executionTime}s\n--"

result.hits.each { hit ->
def path=hit.node.path
String nodePath = node.path;
if (hit.node.hasProperty(propName)) {
count ++;
println 'deleting--'+nodePath ;
node.remove();
/* Save this session if you are sure the correct nodes are being deleted. Once the session is saved the nodes couldn't be retrieved back.
*session.save();*/
}

}

Answers (0)