Try our conversational search powered by Generative AI!

Delete all assets(images) of a specific type

Vote:
 

Hi,

We need to delete about 60000 imageassets (imported from inriver) for a specific type from the web and cm database.

Anyone have any code or sql script for a this operation?

Commerce version: 9.24.1

CMS: 9.12.2

(yeah, I know we should upgrade, but thats another story...)

#200808
Edited, Jan 25, 2019 15:59
Vote:
 

hi, do you care about database only or filesystem as well?

#200828
Jan 26, 2019 19:50
Vote:
 

Just the easiest way of getting rid of all the inriver assets, so that I can re import everything from inriver.

My issue is that some months ago we deleted alle product and items, and as we see now, the linked assets were not deleted, just unlinked in the database. When we now try to import pictures for some of the products, with the same filename, the importcontroller gives an exeception of some kind that the image seo url is already occupied by some other content, so it can't import and link the image. And when I look in the database I see that the old assets existst in the content tables, version tabels and so on. 

So instead of writing a rather complex sql to delete alle the assets, I live in hope that there are an easier and less risky way of deleting all the resources. If not, maybe someone already have written a sql for a similar purpose.

#200838
Jan 28, 2019 10:11
Vote:
 

You would have to write code to delete them, probably by iterating over all products https://leanpub.com/epicommercerecipes/read_sample and then delete each asset in their CommerceMediaCollection (assets are basically content so just use IContentRepository as usual)

It's not fast, but it is the safest way to go 

#200846
Jan 28, 2019 13:57
Vote:
 

Ok, I built something that will iterate through all assets of a specific type in the blockfolders and delete them. Pretty slow though, but a one-time job, so I guess its ok for now.

#200898
Edited, Jan 30, 2019 12:07
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.