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.
Solved! Go to Solution.
Views
Replies
Total Likes
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() }
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
@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.
Why do you want to remove this property?
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() }
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.
Could you provide an example on how JS Script can be used to update node properties? Thanks!
Views
Likes
Replies