AEM asset metadata delete. | Community
Skip to main content
jezwn
December 3, 2021
Solved

AEM asset metadata delete.

  • December 3, 2021
  • 4 replies
  • 3144 views

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. 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by lukasz-m

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()
}

 

4 replies

Siva_Sogalapalli
Community Advisor
Community Advisor
December 3, 2021

@jezwn 

Which version of AEM are you using? I tried the same on AEM 6.5.9 and metadata is not updated. Looks it's an issue.

But did you try to do the same using ACS commons? If not, you can try using acs commons asset importer. 

https://adobe-consulting-services.github.io/acs-aem-tools/features/csv-asset-importer/index.html 

 

 

jezwn
jezwnAuthor
December 6, 2021

@siva_sogalapalli ACS Commons asset importer can't be used to update metadata as the purpose of the tool is to import assets. Feel free to correct me if I'm wrong. And also I needed to have this done for existing assets in DAM.

joerghoh
Adobe Employee
Adobe Employee
December 4, 2021

Why do you want to remove this property?

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
December 4, 2021

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()
}

 

jezwn
jezwnAuthor
December 6, 2021

Thanks @lukasz-m Another solution I tried was creating a package of all the metadata nodes under a path, and then update the xml by emptying the dc:description(done using VS Code searching all occurances under the folder), repackaging and installing it.


Nikhil-Kumar
Community Advisor
Community Advisor
December 6, 2021

@jezwn - Try creating and running your own Groovy/Java/JS script to remove the desired property.

jezwn
jezwnAuthor
December 6, 2021

Could you provide an example on how JS Script can be used to update node properties? Thanks!