[AEM6.5] Unpublish and Removing Bulk Assets [using path from CSV]
Hi Team,
We have a CSV having list of assets to be deleted from instance and the list is in bulk [100+ assets path]
Removal of bulk assets will be one time activity, so what could be the best optimized approach?
eg :
|
Path |
|
/content/dam/test/test-a/image.png |
|
/content/dam/test/test-a/test-image.jpeg |
|
/content/dam/test/test-b/sample.png |
|
/content/dam/test/test-c/image-delete.png |
...100+ records
I was thinking for Groovy script, or servlet to read asset path from CSV and perform activity like unpublish and delete the asset. Any sample solution will be very helpful
Any input: what could be the optimized way to read the path from CSV and then unpublish and remove the asset.
I am quite new to groovy script learning how to manage unpublish and delete assets, till now I did some basic operation like reading and removing the assets.
def csvFile = new File('/path/to/csv/file.csv')
def assetPaths = []
// Read the CSV File line by line
csvFile.eachLine { line ->
def path = line.split(',')[0]
assetPaths.add(path)
}
// Iterate over the asset paths and remove the assets from AEM
assetPaths.each { path ->
def resource = resourceResolver.getResource(path)
if(resource != null) {
resource.delete()
}
But maybe need help to review and how to accomodate unpublish before deleting.
or is this correct approach to remove bulk assets
Thanks
@arunpatidar @kautuk_sahni @briankasingli @vijayalakshmi_s @himanshu_singhal @veenavikraman