AEM asset metadata delete.
How can I remove dc:description from all the assets? I tried with metadata import by emptying the description column, but it isn't working.
How can I remove dc:description from all the assets? I tried with metadata import by emptying the description column, but it isn't working.
Hi @jezwn, I am not sure what exactly is your case, and if this is one time activity or something you would like to proceed regularly. Anyway, below you can find simple groovy script that will remove dc:description completely or just erase the value.
import javax.jcr.query.Query
import org.apache.sling.api.resource.ModifiableValueMap
def query = "SELECT * FROM [dam:Asset] AS s WHERE ISDESCENDANTNODE([/content/dam]) and s.[jcr:content/metadata/dc:description] IS NOT NULL"
resourceResolver.findResources(query, Query.JCR_SQL2).each { r ->
def mvp = r?.getChild("jcr:content/metadata")?.adaptTo(ModifiableValueMap.class)
if(mvp) {
// remove dc:description prpeorty
// mvp.remove("dc:description")
// erase dc:description property value
mvp.put("dc:description", "")
}
resourceResolver.commit()
}
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.