Question

I was just wondering if anyone had any good, and most importantly - quick ways of deleting everything in their blocks / media libraries without having to go through every individual item, and moving it to Trash.

This is something I've been having to do before importing fresh data into my site, the only way I have found of doing it efficiently is to put everything into one folder with sub folders within it, this then allows me to delete the folder and all of its contents. But doesn't really help me with my current project where we already have a ton of assets that I don't really want to go through, moving etc..

I'm surprised there isn't a way to simply clear your library, or even select all and then move to trash?

Thanks, Giuseppe

Was it helpful?

Solution

There is no easy way to do it from the GUI, as far as I know, but you do have the DeleteChildren method on IContentRepository. So creating a scheduled job or a plugin to do it for you should be pretty straightforward.

IContentRepository _contentRepository; // Get this from whereever
var blockRoot = new ContentReference(123); // Get this from whereever, i.e. a property on your startpage

_contentRepository.DeleteChildren(blockRoot, true, AccessLevel.NoAccess);

Also, if you do this on your media data, remember to run the "Remove abandoned BLOBs" scheduled job afterwards (unless it's autorunning on intervals) to clear up disk space.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top